【发布时间】:2018-12-05 23:08:33
【问题描述】:
This is the tag containing href。
This is the HTML of one of the links when I inspected it.
我用来循环链接的代码是:
elems = driver.find_elements_by_xpath("//a[@href]")
for elem in elems:
print(elem)
elem.get_attribute("href").click()
但我得到了错误:
文件“C:/Users/user/Desktop/sel.py”,第 31 行,在
(session="7896348772e450d1658543632013ca4e", element="0.06572622905717385-1")>
elem.get_attribute("href").click()AttributeError: 'str' 对象没有属性 'click'
谁能帮帮我。
【问题讨论】:
-
可以分享相关的html吗?
-
@prany 你想要完整的源代码吗?
-
@vijayMV - 不是整个源代码,而是与您的问题相关的源代码
-
@prany 我在帖子中附上了其中一个链接 html 的图片。
-
我在你的 html 中看不到任何 href
标签: python python-3.x selenium selenium-webdriver webdriver