php - 为什么curl连续请求导致获取数据失败?
ringa_lee
ringa_lee 2017-05-16 13:03:31
0
6
1212

事先需要模拟登录,获取cookie等操作。
然后比如循环请求两个地址a和b:

http://xxxx.xxxx.com/purOrder/getOrderDetailInfo.action?billId=123456

http://xxxx.xxxx.com/purOrder/getOrderDetailInfo.action?billId=654321  

假设a返回3条数据,b返回10条数据
现在问题是,用while循环去请求这两个地址,不管我怎么去刷新,还是请求了a后sleep30秒也好,得到的结果要么就是为空,要么就是a的3条数据,要么就是b的10条数据,总是不能得到a和b的总的数据。
ps:如果我在浏览器登录网站后,直接在浏览器输入a地址,然后输入b地址,数据都是可以获取到的

该怎么办呢?已经折腾好几天了。


把http头打印出来,分别是返回数据的和没有返回数据的
登录后把cookie存在cookie.txt里的,后面的post请求都是把这个文件传进去的,为什么这里cookie会变成这样呢?



这是登录后打印的http头信息



这是保存为cookie.txt的cookie信息

ringa_lee
ringa_lee

ringa_lee

reply all(6)
PHPzhong

Where’s the code

How to confirm the problem without code

为情所困

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
淡淡烟草味

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.

迷茫

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

黄舟


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?

PHPzhong

Do you want to get two handles with one curl request? I don’t understand what you mean

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!