Python Selenium - 如何循环到最后一个 <li>站点中的元素 [英] Python Selenium - How to loop to the last <li> element in a site

查看:25
本文介绍了Python Selenium - 如何循环到最后一个 <li>站点中的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 python selenium 脚本,该脚本应该浏览网站并收集人员个人资料 (https://www.shearman.com/people).该程序不会遍历页面来收集链接.我用过这个不起作用;

I have created a python selenium script that should navigate through a website and collect people profiles (https://www.shearman.com/people). The program won't loop through the pages to collect the links. I have used this which doesn't work;

 try:
     # this is navigate to next page
     driver.find_element_by_xpath('//div[@id="searchResultsSection"]/ul/li[12]').click()
     time.sleep(1)
 except NoSuchElementException:
     break

next 按钮背后的语法如下所示;

The syntax behind the next button can be seen below;

<a href="" onclick="PageRequest('2', event)" class="xh-highlight">&gt;</a>

有人不知道如何编写点击下一步按钮的代码吗?

Does anybody no how to write the code to click the next button?

推荐答案

如果你看HTML元素的图片为>,它是

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