I've been trying to figure this code out with using Beautiful Soup. What I want it to do since it I am pulling various pages and they don't have consistent tags, if it finds one tag to run that code and if it finds another tag to run another code, but I've had no success so far, I'd appreciate some help:
I am not getting any error messages, I do not know if the loop breaks or if it just skips it but it's not printing anything.
The URLs are:
http://store.steampowered.com/app/271590/Grand_Theft_Auto_V/
http://store.steampowered.com/app/578080/PLAYERUNKNOWNS_BATTLEGROUNDS/
The code I have is:
for price in pricing:
if pricing.find('discount_final_price'):
game_price = price.find('discount_final_price')
gamprice = game_price[i].text
print("Price:" + gamprice)
else :
game_price = price.find("game_purchase_price price")
gamprice = game_price[i].text
print("Price:" + gamprice)
hi I dont know what is in the price variable but this code work well :
for price in pricing:
game_price = soup.find('div', class_='discount_final_price')
if game_price != None :
print( "Price : {}".format(game_price.text) )
else :
game_price = pricing.find('div', class_='game_purchase_price price')
print( "Price : {}".format(game_price.text) )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With