如何抓取内容名称由引用定义的javascript页面?

如何抓取内容名称由引用定义的javascript页面?,javascript,python,selenium,selenium-webdriver,web-crawler,Javascript,Python,Selenium,Selenium Webdriver,Web Crawler,该网站是 对不起,这是中文的,但可能与主题无关 目前我可以获取此页面中的所有内容,现在我想转到下一页 页面底部的数字表示页面。目前我在第1页,我想进入第2页。(很抱歉,我没有在这里发布图片的声誉。) 然而,当我试图获取下一页的url时。这似乎是一个动态页面 <td align="left" class="pager" valign="bottom" style="width:60%"> <a disabled="disabled" style="margin-right:5p

该网站是 对不起,这是中文的,但可能与主题无关

目前我可以获取此页面中的所有内容,现在我想转到下一页

页面底部的数字表示页面。目前我在第1页,我想进入第2页。(很抱歉,我没有在这里发布图片的声誉。)

然而,当我试图获取下一页的url时。这似乎是一个动态页面

<td align="left" class="pager" valign="bottom" style="width:60%"> 
<a disabled="disabled" style="margin-right:5px;">首页</a>
<a disabled="disabled" style="margin-right:5px;">上页</a>
<span style="color: red;font-weight: bold;margin-right: 5px;">1</span>
<a href="javascript:void(0)" onclick="QueryAction.GoPage('TAB',2)" style="margin-right:5px;">2</a>
<a href="javascript:void(0)" onclick="QueryAction.GoPage('TAB',3)" style="margin-right:5px;">3</a>
<a href="javascript:void(0)" onclick="QueryAction.GoPage('TAB',4)" style="margin-right:5px;">4</a>
<a href="javascript:void(0)" onclick="QueryAction.GoPage('TAB',5)" style="margin-right:5px;">5</a>
<a href="javascript:void(0)" onclick="QueryAction.GoPage('TAB',6)" style="margin-right:5px;">6</a>
<a href="javascript:void(0)" onclick="QueryAction.GoPage('TAB',7)" style="margin-right:5px;">7</a>
<a href="javascript:void(0)" onclick="QueryAction.GoPage('TAB',8)" style="margin-right:5px;">8</a>
<a href="javascript:void(0)" onclick="QueryAction.GoPage('TAB',9)" style="margin-right:5px;">9</a>
<a href="javascript:void(0)" onclick="QueryAction.GoPage('TAB',10)" style="margin-right:5px;">10</a>

当我尝试使用selenium获取内容时,我无法处理此类javascript代码,因为此按钮的名称是引用形式的。在这种情况下如何进入下一页?

应该可以:

driver.find_element_by_link_text('2').click()
当然,在您的情况下,
2
将动态计算,例如:

cur_page = 1
while True:
    try:
        driver.find_element_by_link_text(str(cur_page)).click()
    except NoSuchElementException:
        break

    # logic

    cur_page += 1