Sep-18-2019, 04:11 PM
I am building an application that compares wine prices, but I ran into a problem.
When I try to get the price of the wine (under the variable "price")it returns "--" instead of the number.
It would be very helpfull if someone knows what is the problem.
Don't hesitate to correct any other mistakes you find in the code.
html from vivino.com:
When I try to get the price of the wine (under the variable "price")it returns "--" instead of the number.
It would be very helpfull if someone knows what is the problem.
Don't hesitate to correct any other mistakes you find in the code.
html from vivino.com:
<div class="text-inline-block header-large light wine-price average__number"> <span class="wine-price-prefix">€</span> <span class="wine-price-value">12,40</span> <span class="wine-price-suffix"></span> </div>my code:
import requests from bs4 import BeautifulSoup wine_to_search = ["Kerner 2017"] user_agent = { "user-agent": 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36' } for item in wine_to_search: url = 'http://vivino.com/search?q=' + item page = requests.get(url, headers=user_agent) soup = BeautifulSoup(page.content, 'html.parser') wine = soup.find(attrs={"bold"}).get_text() price = soup.find(attrs={"wine-price-value"}).get_text() print(wine) print(price)