I want to get the next post page url

Example

domain.com/post-path/

domain.com/post-path/2

domain.com/post-path/3 <– this post has the next page link

but I don’t want to continue. I want the crawler to stop when the path change

domain.com/post1-path/

This is the current code

$attr = isset($nextPageSelector["attr"]) && $nextPageSelector["attr"] ? $nextPageSelector["attr"] : "href";
            if ($nextPageUrl = $this->extractData($this->crawler, $nextPageSelector["selector"], $attr, false, true, true)) {

                $this->postData->setNextPageUrl(Utils::prepareUrl($this->getSiteUrl(), $nextPageUrl, $this->postUrl));
                break;
            }

Read more here: Get next post page url


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: