简体   繁体   English

如何在PHP中使用curl获取所有页面分页数据

[英]How to get all page pagination data using curl in php

I have implemented one data scraping script which fetch data using CURL. 我已经实现了一个数据抓取脚本,该脚本使用CURL获取数据。

But that fetch record only one page but i want all data because on that page pagination is there. 但是,该获取记录仅记录一页,但是我想要所有数据,因为在该页上有分页。

We are getting data using 我们正在使用获取数据

$xpath = new DOMXPath($dom);
$xpath_resultset =  $xpath->query("//div[@class='parentListing']");

in above code parentListing is div class and i am fetching record between div and grep the data using different different class. 在上面的代码中,parentListing是div类,我正在使用不同的不同类在div和grep之间获取记录。

Can any one have idea how to get pagination data of all page. 谁能知道如何获取所有页面的分页数据。

If any one have any suggestion then please help me. 如果有人有任何建议,请帮助我。

Thanks... 谢谢...

I think there is no generic pagination type. 我认为没有通用的分页类型。 You should know pagination element div,ul,li or its name,class name etc. And then you can access pagination links, and sends requests to this links 您应该知道分页元素div,ul,li或其名称,类名称等。然后您可以访问分页链接,并将请求发送到此链接

$xpath = new DOMXPath($dom);
$xpath_resultset =  $xpath->query("//div[@class='parentListing']/a");

Otherwise you must walk all dom and decide which element can be paginate element. 否则,您必须遍历所有dom并确定哪个元素可以是分页元素。 Some pages adds next and previous meta links. 一些页面添加了下一个和上一个元链接。 You can search these tags : 您可以搜索以下标签:

$xpath = new DOMXPath($dom);
$next_resultset =  $xpath->query("//link[@rel='next']");
$prev_resultset =  $xpath->query("//link[@rel='prev']");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM