我想用Selenium检索一个完整的url,使用它的一部分
<div class="productcarousel__mainitem slick-slide slick-current slick-active" data-slick-index="0" aria-hidden="false" style="width: 280px; position: relative; left: 0px; top: 0px; z-index: 999; opacity: 1;" tabindex="-1" role="option" aria-describedby="slick-slide00">
<span class="productcarousel__fullscreen"></span>
<img src="https://cloudxyd.com/image/.../gtfrgrfrtg.jpg">
</div>
我尝试了这个命令,但没有成功:
links = driver.find_elements_by_xpath("//*[contains(text(), 'url(//cloudxyd.com/image/')]")
您也可以使用
css
选择器获取xpath后,必须使用
get_attribute('src')
onlinks
获取url使用以下xpath:
然后获取如下URL:
或者,如果上面提到的xpath突出显示DOM中的多个条目,您可能可以执行以下操作:
相关问题 更多 >
编程相关推荐