【发布时间】:2020-04-19 16:58:39
【问题描述】:
我是 Selenium 的新手,我正在对网站进行网页抓取,因为我想获取标签的所有 href 链接。
我使用了以下代码,但无法获取 href 链接。它显示javascript: 作为输出。
driver.find_element_by_css_selector('div.clFx>a').get_attribute('href')
在其他代码中,这可以正常工作,但在这里它什么也没显示,我还附加了要获取 href 链接的检查元素区域的图像。
我还检查了 Stack Overflow 中的一些答案,并使用了相同的代码,但我仍然无法得到它。
<div class="clFx">
::before
<a class="userName name" href="https://resdex.naukri.com/v2/preview/preview?uniqId=6f44e0e0b95503a44378054b64bdb1cc580e0f001e115d110418475f5808004f130d020214495f5e0b544e170d6&sid=3922138883&paramString=2faf4d57a73f0d419d15309cbc9f5f67134f5108084a5746754e034a571b2513445055524d51250c4b0a1f57504f54030c6&hfFlowName=search&commentSearchType=comment-my,comment-others" target="_blank">Bhimanagoud Patil</a>
::after
</div>
上面的href链接我要搞定。
我已在检查元素的图像下方添加:
【问题讨论】:
标签: python selenium selenium-webdriver xpath css-selectors