我需要在 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 text 值中获取价值?
