如何单击Google搜索结果中的下一个链接? [英] How to click the next link in google search results?

查看:105
本文介绍了如何单击Google搜索结果中的下一个链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Selenium移至google搜索结果的下一页;手动完成后,可以通过在浏览器中单击下一步"来实现.下面是代码段

I am trying to move onto the next-page of the google search results using Selenium; something which can achieved by clicking Next in the browser when done manually. Below is the snippet

browser.get('https://www.google.com')
inputElement = browser.find_element_by_name("q")
inputElement.send_keys('python' + Keys.RETURN)

任何指针或摘要都会很有帮助.

Any pointers or snippets would be helpful.

推荐答案

这很简单:通过文本查找链接:

driver.find_element_by_link_text("Next").click()

演示:

>>> driver.current_url
u'https://www.google.com/?gws_rd=ssl#q=python'
>>> driver.find_element_by_link_text("Next").click()
>>> driver.current_url
u'https://www.google.com/?gws_rd=ssl#q=python&start=10'

这篇关于如何单击Google搜索结果中的下一个链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆