title: How to stop Xpath pagination loop at empty webpage?
body: <p>I have build a spider that scrapes a certain website and it works fine, I used the scrapy for it. The spider scraped all the 430 webpages that I wanted to scrape, by following the 'next page' pagination link. The problem is that the site/scraper also directs to the 431th page, which is empty. And so on. Therefore, the scraper won't stop scraping!</p>
  <p>Can anybody help me to stop the webscraper after all the relevant 430 pages are scraped?? The html code within the last, relevant page is: <a href="https://i.stack.imgur.com/YNVuN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YNVuN.png" alt="HTML code" /></a></p>
  <p>My code is:</p>
  <pre><code>next_page = response.xpath('//a[@id=&quot;nextWebshopsPage&quot;]').attrib['href']
      if next_page is not None:
          yield response.follow(next_page, callback=self.parse)
  </code></pre>