Use Httpclient to simulate login to the educational administration system developed by Zhengfang software Co., Ltd.
I wrote this article in advance, just to share it, there is not only a method to use cookies to log on to the website, but also a method to use random code, I did not reveal my idea of "commercial secrets". I was very easy to learn. I just picked a small apple on the shoulders of giants...
Completing setup ing...
One module is to obtain the student information corresponding to the student ID in the educational administration system and perform subsequent operations! Under normal circumstances, users must log on correctly to implement these functions! I have been learning HttpClient for a while, and I am searching for blogs and demos on the Internet for HttpClent simulated website logon. However, many of the questions I am looking for are as follows: "To get the Verification Code (the educational administration system needs to enter the verification code, can be logged on), and get the cookies, get these cookies, and then add these cookies to the Header during subsequent operations ", with this idea, we can achieve the following, but what I get when I get cookies is "null"
<span style="font-family:Microsoft YaHei;font-size:12px;">List<Cookie> cookies = httpClient.getCookieStore().getCookies();</span>
Because Httpclient was just used, I thought it was my code error, various debugging, no problem. Finally, I used firefox to log on to firefox to view the request information. The strange thing is that no cookies were found,
This is strange. I asked a question in the HttpClent group, some of which are about debugging tools. If I want to do the same, try HttpWatch, FireBug, Google browser, another big brother introduced how to use Fiddler2. The result still does not contain cookies. I had a wry smile, but I found that the Fiddler2 tool is good and the parsing is very detailed. If you are interested, you can download and use it.
I am not always stuck in bid. After a few days, I can't figure it out, so I can find the customer service of Zhengfang software company, I would like to ask how this is achieved by logging on without cookies (it was confirmed that I was so funny that people said it was a trade secret and could not pass it out), and I was a little desperate, search online and simulate login to the Founder System with a try attitude. Hey, I found a lot of entries and finally found a reliable Blog.
Through this Blog, I finally learned the login secret
On the login interface, when the verification code is displayed, the following response header contains the "Location" attribute, and a string of random codes with a length of 24 in the subsequent values, this random code is added to the url in the address bar!
You can use this random code to perform subsequent operations!
This is indeed the case. Through this method, I successfully log in!