运行代码时
def extract():
driver = webdriver.Firefox()
driver.get('http://example.com/')
while True:
elm = driver.find_element_by_link_text(">>").click()
elm.click()
if __name__ == '__main__':
extract()
页面加载,同时单击“下一步”按钮(链接)并加载下一页,
新加载的页面也有相同的链接按钮,但它没有单击
而且,
正在获取错误:
Traceback (most recent call last):
File "C:\Users\Admin\sel\click_next.py", line 14, in <module>
extract_top_news()
File "C:\Users\Admin\sel\click_next.py", line 11, in extract_top_news
elm.click()
AttributeError: 'NoneType' object has no attribute 'click'
这是试图单击的链接按钮
<li>
<a href='http://example.com/page.php?page=2'>>></a>
</li>
我错过了什么!