【发布时间】:2021-03-24 00:44:51
【问题描述】:
我需要在 Python Scrapy 中编写一个选择器。
我想获得 % 的 CBD 和 % 的 THC。
test = productResponse
.css('.woocommerce-product-details__short-description > p')[1]
.get()
当我尝试做这样的事情时,我得到了结果:
<p>
<strong>CBD:</strong> 7.5%<br>
<strong>THC:</strong><0.2%<br>
<strong>Waga:</strong> 1 gram
</p>
但是当我添加 ::text 时,我只得到 CBD 的值:
test = productResponse
.css('.woocommerce-product-details__short-description > p::TEXT')[1]
.get()
结果:
7.5%
如何从 Strong 和 second 文本值中获取值?
【问题讨论】:
-
@Eloims,对不起,但这并不能解决我的问题。我对不排除类的标签有疑问。
标签: css python-3.x scrapy