I am creating a data scraper using scrapy. I shell the product url using
scrapy shell 'https://royalprint.pk/product/name-print-superhero-sweatshirt-011/'
and then run this command
In [43]: response.css('span.woocommerce-Price-currencySymbol::text').get()
Out[43]: 'Rs'
It only returns the currency symbol.
Here is the source code product image
Someone please correct me what I did wrong here ?
Regards
3
Answers
Nothing wrong really, but you just mistaken the element you need to get. I guess you want to get the price number, in that case you should use something like:
as you can see, it’s the
bdi
element the one containing the information you want, not the inner spanIts might help.
The span element you are referencing only contains Rs text.
<span class="woocommerce-Price-currencySymbol">Rs</span>
But the price information you want is after the closing tag of the span element.
The price is included in the bdi element. since we have other bdi elements on the webpage so we need to reference the exact one.
response.xpath("//p[@class='price']//bdi/text()").extract()