参数 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```
Python爬虫:元素属性获取与链接打印
本文演示了如何使用Python的Selenium库来查找网页上的所有`<a>`标签,并通过get_attribute方法正确获取并打印它们的`href`属性。在示例中,发现了一个常见的错误——参数名拼写错误,纠正后的代码能有效抓取链接。
参数 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```
1620

被折叠的 条评论
为什么被折叠?