我有这个HTML,并试图解析条形码
</div>
<div class="bc">
<div class="pititle">
<h2 itemprop="name">Bath Shelf - 5 Pack</h2>
</div>
<div class="brandmanu model">
<h5>Product code</h5>
<h6>BA0576</h6>
</div>
<div class="brandmanu gtin">
<h5>Barcode</h5>
<h6>5056170307192</h6>
</div>
<div class="brandmanu inner">
<h5>Inner Barcode</h5>
<h6>NO INNER</h6>
</div>
<div class="brandmanu outer">
<h5>Outer barcode</h5>
<h6>25056170307196</h6>
</div>
<div class="brandmanu brand" itemprop="brand" itemscope="" itemtype="http://schema.org/Brand">
我尝试编写此代码,但没有得到结果:
element = driver.find_element_by_class_name("brandmanu gtin")
tag_list = driver.find_elements_by_xpath("//div[@class='brandmanu gtin']")
print(element)
print(tag_list)
对于find_element_by_class_name
,我得到一个错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".brandmanu gtin"}
(Session info: chrome=89.0.4389.90)
请告知,如何修复代码
通过
css
选择器获取它:要获取值,请使用:
点是用来上课的
如果您更喜欢
xpath
:相关问题 更多 >
编程相关推荐