This repository was archived by the owner on Jan 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,23 @@ $ composer require xparse/recursive-pagination
3030 $paginator->addToQueue('http://www.example.com/first/page/to/parse.html');
3131
3232 $allLinks = [];
33- while ($page = $paginator->getNextPage()) {
33+ while ($page = $paginator->getNextPage()) {
3434 $adsList = $page->attribute("//div[@class='itemdetails']//a/@href")->getItems();
3535 $allLinks = array_values(array_unique(array_merge($allLinks, $adsList)));
3636 }
3737 print_r($allLinks);
38+
3839```
40+ You can also specify custom xpath string or array to getNextPage() method
41+
42+ ``` php
43+ while ($page = $paginator->getNextPage("//a[@class='pagination']/@href")) {
44+ $adsList = $page->attribute("//div[@class='itemdetails']//a/@href")->getItems();
45+ $allLinks = array_values(array_unique(array_merge($allLinks, $adsList)));
46+ }
47+ print_r($allLinks);
48+ ```
49+
3950
4051## Testing
4152
Original file line number Diff line number Diff line change @@ -29,9 +29,9 @@ class RecursivePagination {
2929
3030 /**
3131 * @param Grabber $grabber
32- * @param array $xpath
32+ * @param null $xpath
3333 */
34- public function __construct (Grabber $ grabber , $ xpath = [] ) {
34+ public function __construct (Grabber $ grabber , $ xpath = null ) {
3535 $ this ->grabber = $ grabber ;
3636 $ this ->addXpath ($ xpath );
3737 }
You can’t perform that action at this time.
0 commit comments