Scrapy 拼凑文本提取不正确
我有个问题 我想得到一个网站上的文字(价格)。所有其他的东西,比如标题/名字,都有效,但价格不起作用Scrapy 拼凑文本提取不正确,scrapy,Scrapy,我有个问题 我想得到一个网站上的文字(价格)。所有其他的东西,比如标题/名字,都有效,但价格不起作用 price=product.css('.offerList item priceWrapper.priceRange::text')[0].extract().replace('ab','').replace('*','').replace('\xc2','').replace('\xa0','').replace('€','').strip() 这就是价格决定 这就是html站点 <di
price=product.css('.offerList item priceWrapper.priceRange::text')[0].extract().replace('ab','').replace('*','').replace('\xc2','').replace('\xa0','').replace('€','').strip()
这就是价格决定
这就是html站点
<div class="offerList-item-priceWrapper">
<div class="offerList-item-pricePrefix">
<span></span>
<span class="offerList-item-pricePrefixCount">62 Angebote</span>
</div>
<div class="priceRange">
<span class="priceRange-from">
<span class="price-from">
ab</span>
<span class="price-currencySymbol price-currencySymbol--before">€</span>
30,82<span class="price-currencySymbol price-currencySymbol--after"> €</span>
</span>
<span class="priceRange-to">
<span class="price-currencySymbol price-currencySymbol--before">€</span>
126,61<span class="price-currencySymbol price-currencySymbol--after"> €</span>
</span>
</div>
</div>
62安格博特
ab
€
30,82 €
€
126,61 €
你不能说真的有很多空白。。。
如果我打印我的价格,我只会得到空白
我在这里放了一个截图,在那里你可以看到chrome的控制台
我认为有太多的空白,所以我没有得到那个例子中的30,82 我设法为您简化了不少
pricerange-from = product.css('div.priceRange span.priceRange-from::text').getall()[2].strip()
pricerange-to = product.css('div.priceRange span.priceRange-to::text').getall()[1].strip()
多练习使用选择器。希望这个答案能告诉你哪里出了问题