Issue
I am having trouble extracting the "ADD TO CART" text from this HTML code. I'm new to web scraping so I don't know how to approach this. I need your help.
<button data-t-events="A" data-t-e-var78="$ - Add To Cart" type="button" class="btn btn-primary btn-wide" data-reactid=".8.1.0">
<span data-reactid=".8.1.0.0" class="">ADD TO CART </span><i class="fa fa-caret-right" data-reactid=".8.1.0.1"></i></button>
I have tried
products = response.css('.btn-wide::text').extract_first()
print(products)
and
products = response.css('.btn-wide span::text').extract_first()
print(products)
Solution
a way using XPath and data_reactid
is:
response.xpath('//span[@data-reactid=".8.1.0.0"]/text()').get()
Answered By - Moein Kameli
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.