Python Forum
web scrape not returning number correctly
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
web scrape not returning number correctly
#1
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:
<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)
Reply


Messages In This Thread
web scrape not returning number correctly - by willyflapoor - Sep-18-2019, 04:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  scrape data 1 go to next page scrape data 2 and so on alkaline3 6 5,215 Mar-13-2020, 07:59 PM
Last Post: alkaline3

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020