I made a price tracker but it’s not working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I made a price tracker but it’s not working

import requests from bs4 import BeautifulSoup import smtplib URL = 'https://www.ebay.ca/itm/83848-Asus-FX505DY-Tuf-Gaming-Laptop/324140922330?hash=item4b784df5da:g:YZ4AAOSwJjtenMSo' headers = { "user-agent": 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36'} def check_price(): page = requests.get(URL, headers=headers) soup = BeautifulSoup(page.content, 'html.parser') title = soup.find(id="itemTitle").get_text() price = soup.find(id="mm-saleDscPrc").get_text() converted_title = title[17:54] converted_price = price[3:6] if (converted_price < 650): send_mail() print(converted_title) print(converted_price) def send_mail(): server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() server.ehlo() server.login('email@gmail.com', 'password') subject = 'Price fell down!' body = 'Check the link! https://www.ebay.ca/itm/83848-Asus-FX505DY-Tuf-Gaming-Laptop/324140922330?hash=item4b784df5da:g:YZ4AAOSwJjtenMSo' msg = f"Subject: {subject}\n\n{body}" server.sendmail( 'Email@gmail.com', 'Email@gmail.com', msg ) print("EMAIL SENT!") server.quit() check_price() Basically when I run it nothing happens and I don’t understand why could anyone help me? Much appreciated!

20th Apr 2020, 7:21 PM
Blaize
Blaize - avatar
1 Answer
0
'check_price()' is indented to 'send_mail()' function? Also 'converted_price < 650' Throw an exception, because containing elements that have varying data types e.g.(strings and/or floats).
22nd Apr 2020, 1:23 AM
xLord
xLord - avatar