I am trying to scrape of prices of products from different webshops.
I am doing this in Python
with requests
and BeautifulSoup
.
I want to scrape a price of a product but I don't see it come up in the output.
My code looks like this:
response = requests.get('https://www.fritz-berger.de/suche?q=8710315990829')
soup = BeautifulSoup(response.content, 'html.parser')
print(soup.prettify())
Normally I want to get the price with regex
but i don't see it anywhere. I am missing something?
CodePudding user response:
EDIT
You are using a specific setting concerning delivery to NL not DE, so it won´t find a result for a basic request to show up or redirect. So may try the XHR request to their search api and use fv=NL
to specify:
https://search.epoq.de/inbound-servletapi/getSearchResult?full&callback=jQuery360016688827514037174_1673258199659&tenantId=fritz-berger-de&sessionId=c29bb0e240b3a0c61f643287bc3362d&orderBy=&order=desc&limit=30&offset=0&locakey=&style=compact&format=json&nrf=&query=8710315990829&ff=e:whitelist_country&fv=NL&_=1673258199660
This would be predestined for asking a new question with exact this focus.
Try to use a link or a relevant search term that is valid and leads to a product. Yours will lead to an empty search results page.
import requests
from bs4 import BeautifulSoup
response = requests.get('https://www.fritz-berger.de/suche?q=452210')
soup = BeautifulSoup(response.content, 'html.parser')
soup.select_one('.current-price').get_text(strip=True).split('€')[0]
-> 5,99