xpath捕获内容出现‘list‘ object has no attribute ‘get_attribute‘
问题
在用selenium捕获网页里面所有标签a包含的href
写了如下的代码
item=find_elements_by_xpath("//a")
for it in item:
print(it.get_attribute('href'))
然后就报错了!it没有这个属性
解决
我把it.get_attribute('href')
改成了it.get_attribute("href")就行了
很迷惑,完全不知道为啥
贴一个python单引号和双引号的区别传送门
...
原创
2022-04-02 14:03:14 ·
3294 阅读 ·
0 评论