开发者

How to login to a webpage and get its html code with Java, when it uses post method for logging in?

I created an application tha开发者_如何学Got parses content of secured areas of one webpage after account information input. It used GET method for loging in, so it was quite simple, I just used URL to log in. Now it was changed to POST method and I wonder how to log in to that site? The login form uses 2 input tags of type text with names 'login' and 'pass'.


Are you using something like apache commons http. You can use post method.


Have you tried setting the request method?

HttpURLConnection conn = new HttpURLConnection(url);
conn.setRequestMethod("POST");
OutputStream os = conn.getOutputStream();
os.write(...);
Object content = conn.getContent();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜