我使用Beautifulsoup4来解析网页。与Bing的工作方式类似,如果您输入搜索词,则它将返回前10个匹配,并在第2页,第3页等列出的后续页面上进行后续匹配...查询确实包含第2页的超链接后返回的第一个页面直到最后一页。我想要建立的正是最后一页(例如,第87页)。使用Python的网页表格中的最后超链接
下面是从页面的HTML源代码的样本:
<tr><td colspan=4 align=left class='uilt'>����� ������� ��������: 3543.<br>��������: 1 <a href="/main/search.php?str=&tag=&nopass=&cat=25&page=2">2</a> <a href="/main/search.php?str=&tag=&nopass=&cat=25&page=3">3</a> <a href="/main/search.php?str=&tag=&nopass=&cat=25&page=4">4</a> <a href="/main/search.php?str=&tag=&nopass=&cat=25&page=5">5</a> <a href="/main/search.php?str=&tag=&nopass=&cat=25&page=6">6</a> <a href="/main/search.php?str=&tag=&nopass=&cat=25&page=7">7</a> <a href="/main/search.php?str=&tag=&nopass=&cat=25&page=8">8</a> <a href="/main/search.php?str=&tag=&nopass=&cat=25&page=9">9</a> <a href="/main/search.php?str=&tag=&nopass=&cat=25&page=10">10</a> <br></td></tr>
在上面的例子中,我将如何制定出的最后一个环节是10页?上面有更多的HTML,所以我不能简单地从HTML代码的末尾分割X个位置。
感谢
你需要使用BeautifulSoup吗?如果你使用Selenium,你不需要它。 – 2015-03-08 22:03:12
我使用Beautifulsoup进行大部分解析,只是使用硒来模拟用户实际输入的特定术语 – thefragileomen 2015-03-08 22:04:48