A problem occurred when the Curl method captured the page. Recently, a score query proxy system was created. the curl method was used to simulate logon to the school's educational administration system (written in ASP and poorly written ), capture the information and then display the content.
After that, the school's educational administration system changed to a new one, which was written in JSP. the verification code function was added. then, I obtained the verification code, input it, and submitted the HTTP request using the curl method, however, all the captured results are returned.
"The database is busy. please try again later"And I typed out the URL and directly entered it in the address bar to enter the educational administration system. In addition, when I used POSTMAN to initiate an HTTP request, the GET and POST methods can all enter the system, only the CURL method of PHP will show "database busy ".. Later, I wrote a similar piece of code in ruby, using the net: http method. I also wrote "Please try again later when the database is busy", and I can also copy the URL to the address bar .. I don't know where the problem is .. For help ..
..
echo $url.'
';$ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $content = curl_exec($ch); curl_close($ch);echo $content;
No other setopt is added to the code .. Please kindly advise .. What is the problem ..
Reply to discussion (solution)
// Try curl_setopt ($ c, CURLOPT_USERAGENT, 'mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; c8650 Build/GWK74) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 MQQBrowser/4.5 Mobile Safari/533.1s ');
Estimate? Sentence? User agent ,? Master mode? I? Look.
// Try curl_setopt ($ c, CURLOPT_USERAGENT, 'mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; c8650 Build/GWK74) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 MQQBrowser/4.5 Mobile Safari/533.1s ');
Reply 1L:
At first, I thought it was a problem with the UserAgent, but it was still "busy with the database"
Estimate? Sentence? User agent ,? Master mode? I? Look.
Added the setopt of User Agent on the first floor, which is still "busy Database"
Print_r (file_get_contents ($ url ));
What is this prompt?
Yes? Strange, estimate? The header is somewhat different.
Print_r (file_get_contents ($ url ));
What is this prompt?
It is also shown in "database busy "...
Is it because of the verification code?
Paste the captured package.
I forgot to mark the last reply.
Paste the captured package.
The above is the request header for successful login
This is the request header I have simulated ..
1. he has a verification code. How did you handle it?
2. he has a cookie and does not see how you handle it.
Paste the captured package.
The above is the request header for successful login
This is the request header I have simulated ..
I only read the parameters of your url with verification code, but did not see Cookie processing. I tried to add cookie-related parameters to curl.
The use of curl cookejar, set opt header, and online search should be able to produce results.
Thank you for your reply.
The specific problem lies in the cookie. we thought we had to obtain the cookie only after logging on, and then perform subsequent operations. then we found that a JSESSIONID (cookie) will be assigned when obtaining the verification code ), when logging on, you need to submit the cookie together, and then I write
Continue to the uncompleted part of the upstairs:
Write a curl that simulates the access verification code address, get the cookie, and save it,
Then, the verification code is displayed, the form is submitted, and the postfileds and cookie are submitted together, and the simulation is successful ..
Thank you very much. close the post now.