XPath:如何停止分页循环

时间:2018-11-01 01:27:51

标签: xpath web-scraping

我正在尝试从多个页面中提取数据,并拥有一个XPath可以成功分页所有页面,但是却陷入了最后一页的无限循环。在此XPath中应该进行哪些更改,以使其不会卡在最后一页的循环中?

检测所有页面但卡在最后一页的循环中的XPath:

.//*[@class="active-info"]/following-sibling::li[1]/a

这是源代码:              

        <li><a href="" style="pointer-events:none"><span Class="glyphicons glyphicons-more-items glyphicon-adjust-btn-group-sm"></span>Page:</a></li>
            <li class="active-info"><a href="/variety/list/ma/upcoming/page-1">1</a></li>
            <li class=""><a href="/variety/list/ma/upcoming/page-2">2</a></li>
            <li class=""><a href="/variety/list/ma/upcoming/page-3">3</a></li>
            <li class=""><a href="/variety/list/ma/upcoming/page-4">4</a></li>
            <li class=""><a href="/variety/list/ma/upcoming/page-5">5</a></li>
            <li class=""><a href="/variety/list/ma/upcoming/page-6">6</a></li>
    <li><a href="" style="pointer-events:none"><span Class="glyphicons glyphicons-list glyphicon-adjust-btn-group-sm"></span>1 to 20 of 119</a></li>
</ul>

0 个答案:

没有答案