问题
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.
回答1:
Filter by text
.paginate('.paginate a:contains(Next)@href')
回答2:
mybe this can help you write this in paginate
.paginate('.paginate > li.current + a > a@href')
or
.paginate('.paginate > li.current > a@href')
thanx
来源:https://stackoverflow.com/questions/44885793/x-ray-paginate-filter-by-text