尝试了下百度的代码, 都是返回原网页,并没有返回登录跳转之后的网页啊。
到底要怎么进行模拟表单提交啊?
大家讲道理2017-04-18 09:05:35
There are many http frameworks. There is no need to write all http requests yourself. For example, there is okhttp, and there is also an annotation-based http framework: retrofit.
阿神2017-04-18 09:05:35
模拟表单提交很好搞啊:
<form action="填写你要请求的url地址">
name: 参数一
password:参数二
</form>
相当于执行了:url?参数一=111&参数二=333
黄舟2017-04-18 09:05:35
HttpURLConnection will not jump based on the return code
You need to parse the HTTP status code from the result. If it is 302, then take out the referer attribute in the returned HTTP header. This is the address to which you will be redirected after logging in
It will be OK to initiate the request again after redirecting the address
It is not recommended to use JDK’s HttpURLConection, which is not easy to use. It is recommended to use Apache httpClient or OKHTTP