I am writing a program that asks the user for a baseball player and a card number and it will return the card's value. I am using BeautifulSoup to web scrape https://mavin.io/search?q= and finding the value referenced in the code below. When I type in Mike Ivie, with card number 45T, the program creates the URL, https://mavin.io/search?q=mike+ivie+45T. From there I want to get the price in the green box Shown here. I keep getting this as a result, Click for result.
Can anyone help out?
from bs4 import BeautifulSoup import requests import re print('\t Want to know the value of your baseball card?') print('You found the place, enter the name of the player and the card number below.') print('Enter "STOP" as the player name when you are done.') print('----------------------------------------------------------------------------') url = 'https://mavin.io/search?q=' choice = False while not(choice): player = input('Player Name: ').lower() card_number = input('Card Number: ') checkPlayer = list(player) for i in range(0,10): if str(i) in checkPlayer: print() print('-----------------------------') print('You entered an invalid input!') print('-----------------------------') continue if player == 'stop': choice = True print() print('--------------------------------------------') print('Thank you for using this tool. See you again') print('--------------------------------------------') else: #add contents to end of url finalPlayer = player.split(' ') for i in range(len(finalPlayer)): url += finalPlayer[i] + '+' url += card_number source = requests.get(url).content soup = BeautifulSoup(source,'lxml') article = soup.find('div', class_ = 'estimate-box equal-width') print(article.h4)
https://stackoverflow.com/questions/66809051/using-beautifulsoup-in-python-it-returns-none-surrounded-by-h4-tags March 26, 2021 at 07:40AM
没有评论:
发表评论