我使用Scrapy并基于XPATH选择器编写脚本。我尝试搜索XPATH语法来收集两个值:price和EAN编号(500.02,08043687312822)。价格:500,2和EAN:08043687312822
<div class="emProductPrice">
<span itemprop="offers" itemscope="" itemtype="http://example.com/Offer">
<span
itemprop="price" content="500.02">500,02</span> hrywna<meta itempr\
op="priceCurrency" content="PLN">
<meta itemprop="gtin14"
content="08043687312822">
<link itemprop="itemCondition"
href="http://example.com/NewCondition">
<l\ink itemprop="availability" href="http://example.com/InStock">
</span>
</div>
我尝试编写类似于//div[@class="emProductPrice"/span/span/text()
的语法,但我只得到:&amp; nbsp。我需要500,02例如
这是怎么回事?请帮忙。
答案 0 :(得分:1)
你需要:
price = response.xpath('//span[@itemprop="price"]/@content').extract_first()
ean = response.xpath('//meta[@itemprop="gtin14"]/@content').extract_first()