Which of the following is the optimal solution for loop reading with paging interface?

Source: Internet
Author: User
Currently, third-party interface data needs to be read. the data volume is large, and the third-party only uses the paging method. Currently, my solution is to call the curl read interface method in a loop, convert json data to an array and filter and store the data in the spliced array. However, the third-party interface does not... currently, third-party interface data needs to be read. the data volume is large, and the third-party only uses the paging method. Currently, my solution is to call the curl read interface method in a loop, then, convert json data into arrays and filter and store the data in the spliced array. However, the read may fail due to the instability of third-party interfaces. Is there a better solution?

Reply content:

Currently, third-party interface data needs to be read. the data volume is large, and the third-party only uses the paging method. Currently, my solution is to call the curl read interface method in a loop, then, convert json data into arrays and filter and store the data in the spliced array. However, the read may fail due to the instability of third-party interfaces. Is there a better solution?


If the data volume is large, you can use a scheduled script to pull the data.
When pulling data, sort it by a field such as auto-increment id to avoid paging data changes.
Then, when the script is executed or when the loop ends, write down the largest id, and then add the condition greater than this value to the next execution.

When the script is executed, if the interface call fails, you can try to pull the script several times again. if the script fails, stop the script execution, write down the id, and then give the warning information and manual intervention.
Amount, simple ideas


1. it is recommended that you create a grabbing source database, and the id or md5 should be good to ensure the uniqueness of a single data capture.
2. the interface is unstable. you can handle curl failure exceptions to ensure data capture is successful.
3. Prepare for repeated data capturing. based on 1, ensure that the data is not processed repeatedly.

The above is what kind of content is the optimal solution for loop reading with paging interface. For more information, see PHP Chinese network (www.php1.cn )!

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.