我试图使用selenium python捕获网页的产品大小
<h4 class="product-sizes">
<!-- react-text: 510 -->Sizes:
<!-- /react-text -->
<span class="product-sizeInventoryPresent">UK6,
</span><span class="product-sizeInventoryPresent">UK7,
</span><span class="product-sizeInventoryPresent">UK8,
</span><span class="product-sizeInventoryPresent">UK9,
</span><span class="product-sizeInventoryPresent">UK10,
</span><span class="product-sizeInventoryPresent">UK11
</span>
</h4>
基本上,输出应该在类product-sizeInventoryPresent
下列出所有大小,即大小=[UK6、UK7、UK8、UK9、UK10、UK11]。
到目前为止我试过这个
sizes = browser.find_elements_by_class_name('product-sizes')
size_list = []
for size in sizes:
size_list.append(size.text)
但它返回一个空列表。主要是因为product-sizeInventoryPresent
仅当我将鼠标悬停在元素上时才可见
在selenium中,找到父元素后,可以使用父元素搜索子元素
请尝试以下代码:
输出
相关问题 更多 >
编程相关推荐