Use httpClient to log in. There are many codes found online, but they are authentic. The reliability is not high. I found someone who logged into Kaixin.com, and it was obvious that I used the wrong cookie. It is so important to post a code on the Internet, and the same code is everywhere, and I can’t tell whether it is original or not. If it is good and useful, Forget it, if not, then what's the point, is it to attract criticism?
Due to work needs, I had to capture data from other systems. After some study, I chose httpClient+htmlParser. I read articles on the IBM community. Given its reputation, it is relatively easy to cheat.
I won’t go into the basics. I created a new client and method, added a username and password, and logged in. It’s not right. I added various request headers and parameters and tried everything I could find, but the result remains the same. The wrong password also returns 200, because when he found the jsp, he thought it was 200 and did not log in at all. And it shouldn’t be 200, it should be 302, which will definitely be forwarded after logging in. Can't figure out why 200. I searched and searched on csdn, and finally saw a post ( http://topic.csdn.net/u/20090105/17/dd8c1875-934e-4049-b5fe-706d78f6cb75.html ), which woke me up from my dream. The j2ee system finally executes the request by action. It is useless to submit the request to login.jsp for execution. The login action must be submitted to the login. Struts or webwork system all accesses the action and then returns jsp. Different from PHP, it is all pages and there is no concept of "backend" like J2EE.
Change the url to action, and the problem will disappear. It will also be 302, and I can see it being forwarded.
PS: I wrote it myself to log in to Kaixin.com and gave me a 408, but I probably don’t have time to study it.
This article comes from the CSDN blog. Please indicate the source when reprinting: http://blog.csdn.net/sysmaid/archive/2009/12/30/5105039.aspx