You need to simulate login, obtain cookies and other operations in advance.
Then for example, loop to request two addresses a and b:
http://xxxx.xxxx.com/purOrder/getOrderDetailInfo.action?billId=123456
http://xxxx.xxxx.com/purOrder/getOrderDetailInfo.action?billId=654321
Suppose a returns 3 pieces of data and b returns 10 pieces of data
The problem now is, use a while loop to request these two addresses. No matter how I refresh it, or sleep for 30 seconds after requesting a, I will get The result is either empty, 3 pieces of data for a, or 10 pieces of data for b. The total data of a and b cannot always be obtained.
ps: If I log in to the website in the browser and directly enter the a address in the browser, and then enter the b address, the data can be obtained
What to do? I've been struggling with this for several days.
Print the http headers, those that return data and those that do not.
After logging in, store the cookie in cookie.txt. Subsequent post requests will all pass this file in. Why does the cookie change here? What happened?
< br>This is the http header information printed after logging in
< br>This is the cookie information saved as cookie.txt
< /p>
为情所困2017-05-16 13:05:31
Sometimes curl operators will run into a bunch of problems that they cannot solve if they use them improperly. What should we do in this case? Find a wheel to solve it! !
I happened to use /a/11...
when I posted on Douban last time淡淡烟草味2017-05-16 13:05:31
There is no specific website address, and it is difficult to locate the problem for you. I guess it is because your login cookie is wrong, and A does not meet the conditions to verify your identity, so it only returns data that can only be seen by anonymous users.
迷茫2017-05-16 13:05:31
No need to loop. Directly file_get_contents in the page, that is, request each one individually to see if the returned result is correct
黄舟2017-05-16 13:05:31
Print out the http headers, those that return data and those that do not.
After logging in, store the cookie in cookie.txt. Subsequent post requests will all pass this file in. Why is the cookie here? What if it becomes like this?
PHPz2017-05-16 13:05:31
Do you want to get two handles with one curl request? I don’t understand what you mean