I am very confused about a curl-php Tutorial.

Source: Internet
Author: User
I am very confused about a curl issue. I used curl to simulate Baidu's access Promotion. my goal is to use cookies to obtain the json data in it, as shown below: 1. log on to the Baidu promotion website through simulated login. 2. Then, use the cookie and post parameters to obtain json data. 3. Parse and import the obtained json data into the database. The problem is: when I got half of the data, the code showed that I could not get the json data. Then I re-execute the script to find a question about curl that makes me very difficult.
I used curl to simulate the promotion of Baidu. my purpose is to obtain the json data in the cookie. the current situation is as follows:

1. log onto the Baidu promotion website through simulated login
2. then obtain json data through the cookie and post parameters.
3. Parse and import the received json data to the database

Now the problem is: when I get half of the data into the database, the code shows that the json data cannot be obtained. Then I re-execute the script and the result is that the first half of the data cannot be obtained. (although I have already stored this half of the data, I can re-obtain it, in principle, json data is returned ).

My understanding is that the curl access may be faulty when the json data is retrieved (but this should not be a code issue because half of the data has been obtained before, this is like a sudden disconnection from the Internet)

I would like to ask you if this problem has not occurred when you use curl. please answer!


------ Solution --------------------
All data is obtained, data integrity is judged, and then the write operation is performed ..
------ Solution --------------------
This is not the case. it is obtained only when the sent request completely returns the curl, and the post request receives a response, either completely or completely. This is not like displaying web pages. sometimes only some of them are loaded and some of them are not displayed.
------ Solution --------------------
Yes, your request is sent too fast, and the other party blocks you temporarily,
Sleep between requests several seconds .....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.