Skip to content
Advertisement

Amazon Web Scraping – retrieving price data

I’m currently working on my first project experimenting with web scraping on python. I am attempting to retrieve price data from an amazon url but am having some issues.

JavaScript

When I print the price variable, my output is a bit weird:

JavaScript

There’s alot of whitespace and the numbers are formatted in weird way with a alot of newline. How do I gather just the price so when I print it should just display $394.00?

I believe this can be solved with the span class but I could not figure it out.

Advertisement

Answer

As you can see below, searching for “corePriceDisplay_desktop_feature_div” is far to broad. Searching for span element with class=”a-offscreen” should fit your needs.

Try:

price = soup.find(“span”, {“class”: “a-offscreen”})

enter image description here

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