python - Selenium 在元素中查找元素

标签 python selenium web-scraping

我知道这个问题似乎以前曾被问过,但当我尝试模仿其他人的回答时,仍然存在问题。

我的代码是:

table = driver.find_element_by_xpath('//*[@id="tabdocsumtable"]/tbody')      
entries = table.find_elements_by_class('rprt')

我正在获取

AttributeError: 'WebElement' object has no attribute 'find_element_by_class'

网页链接:https://www.ncbi.nlm.nih.gov/clinvar/?term=setx%5Bgene%5D

最佳答案

根据the python binding docs ,看起来 python 的方法是 find_elements_by_class_name

所以这一行:

entries = table.find_elements_by_class('rprt')

应该是:

entries = table.find_elements_by_class_name('rprt')

关于python - Selenium 在元素中查找元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44441701/

相关文章:

python - 如何在启动时运行 python 程序(包含 tkinter)

python - Python:尝试让音频间隔播放

html - 检查HTML是否通过xpath,Selenium IDE包含文本

javascript - 抓取javascript网站

node.js - 在每个循环内调用cheerio.load

python - 使用唯一值更改重复项

python - 我应该在哪里对对象和字段进行 Django 验证?

java - Selenium Chromedriver - 正常打开 Chrome

java - WebDriver:设置初始 URL

html - 如何使用 CSS 从网站(提供的链接)中抓取表格?