作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<td>
<div class="buy_car_list_img">
<a href="buy_detail.aspx?TSEQNO=5002081">
<img src="http://www.xxxxx.com//UPLOAD/AM/BF5054/26531.jpg" width="100">
</a>
</div>
</td>
我想获取href的url。
buy_detail.aspx?TSEQNO=5002081
代码:
g=driver.find_elements_by_class_name("buy_car_list_img")
#print(g)
for item in g:
print(item.get_attribute('href'))
当我打印此内容时,它返回“无”,任何建议都会受到赞赏。
最佳答案
class
位于没有 href
属性的 div 上。您想要获取 a
标记。试试find_elements_by_css_selector
g = driver.find_elements_by_css_selector('.buy_car_list_img a')
关于Python:无法从 webdiver 获取 href,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51700417/
我想获取href的url。 buy_detail.aspx?TSEQNO=5002081 代码: g=driver.find_elements_by_
//I have used waits like Thread.sleep(2000); 或 driver.manage().timeouts().pageLoad(100,TimeUnit.seco
我是一名优秀的程序员,十分优秀!