开发者

Java - reading data from website requiring login

开发者 https://www.devze.com 2023-04-11 05:25 出处:网络
I\'m basically trying to us开发者_如何学Ce Java to read some data from my school\'s website (homework assignments, which lessons I have and when, etc.) for personal use. However, my school requires on

I'm basically trying to us开发者_如何学Ce Java to read some data from my school's website (homework assignments, which lessons I have and when, etc.) for personal use. However, my school requires one to be logged in to access this information.

Could anyone point me in the right direction for logging in with code and accessing this information?

Thanks, Mike.


The Apache has a API for http client simulating.

Link: http://hc.apache.org/httpcomponents-client-ga/


You need to find out how the server handles logins. What authenticationer it used: cookies, url session id, etc. Then you can send the server a login http form submit (as you would have done manually) and save the authenticationer. With the authenticationer you can then access the secured sites.


I would use HtmlUnit, which is a programmatic web browser.

You tell it to load the authentication page, to fill the form with your credentials and to click on the submit button. The you click on links, just as you would do it with a real browser, but programmatically, using Java instructions.

And it even supports JavaScript, if necessary.

0

精彩评论

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

关注公众号