0

I'm trying to web scrape the product price on this site: https://www.webhallen.com/se/product/232445-Logitech-C920-HD-Pro-Webcam

I tried using

price = str(soup.find('div', {"class": "add-product-to-cart"}))

and

price = soup.find(id="add-product-to-cart").get_text()

But unfortunately, I had no luck. The item returns no price. The price/text is stored in a span class.

1 Answer 1

1

The entire website is behind JavaScript so you won't fetch anything with bs4. However, there's an API endpoint with all the data you need.

Here's how to get it:

import requests

with requests.Session() as session:
    response = session.get("https://www.webhallen.com/api/product/232445").json()
    print(response["product"]["price"]["price"])

Output:

1190.00
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.