node.jsx-ray

X-Ray Paginate filter by text


I am using x-ray to scrap a webpage with pagination. Here are some HTML

<td align="center" style="font-size: 11pt;">
  <div class="paginate" style="font-size: 11pt;">
    <span class="disabled">Previous</span>
    <span class="current">1</span>
    <a href="link2.html">2</a>
    <a href="link2.html">Next</a>
  </div>
</td>

I would like to scrap by the Next button. But the web page example is scraped by it's class name.

x('https://blog.ycombinator.com/', '.post', [{
  title: 'h1 a',
  link: '.article-title@href'
}])
  .paginate('.nav-previous a@href')

I would like to know how can I paginate by choosing the link in the Next button?

Thanks in advance.


Solution

  • Filter by text

    .paginate('.paginate a:contains(Next)@href')