Skip to content
Advertisement

Scraping data through changing Xpaths

I can’t figure out how to scrape data, I am trying to scrape the product name, price and other information from the website, the product names are easy to access as they have similar xpath with only one tag that changes but for the prices the there are multiple changes to the tags.Is there an alternative to how I can scrape data without the xpath as class name and ID return an empty string.

JavaScript

Advertisement

Answer

You no need to use hardcoded loop, rather identify unique xpath to identify parent element and then child element. Only ratings not avail for every product where you can use try..except block.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement