首页 Python python – Selenium’WebElement’对象没有属性’Get_Attribute’

python – Selenium’WebElement’对象没有属性’Get_Attribute’

我正在使用Selenium webdriver(chrome)和 Python,试图从页面上的所有链接获取href.当我尝试以下内容时: items = driver.find_elements_by_tag_name(a)print itemsfor item in items: href = item.Get_Attribute(href) print href

我正在使用Selenium webdriver(chrome)和
Python,试图从页面上的所有链接获取href.当我尝试以下内容时:

items = driver.find_elements_by_tag_name("a")
print items

for item in items:
    href = item.Get_Attribute('href')
    print href

它设法获取所有链接,但在get_attribute上我收到一个错误:

‘WebElement’对象没有属性’Get_Attribute’

虽然我看到的任何地方似乎都应该有效.

有解决方案吗

谢谢!

解决方法

“Get_Attribute”属性不存在,但“get_attribute”属性执行:

items = driver.find_elements_by_tag_name("a")
print items

for item in items:
    href = item.get_attribute('href')
    print href

本文来自网络,不代表青岛站长网立场。转载请注明出处: https://www.0532zz.com/html/kaifa/python/20201117/12382.html
上一篇
下一篇

作者: dawei

【声明】:青岛站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

返回顶部