forked from buraksarpkaya89/Python-shopping-CheckPrice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
46 lines (38 loc) · 1.34 KB
/
app.py
File metadata and controls
46 lines (38 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import requests
from bs4 import BeautifulSoup
import smtplib
import time
url = input('Urun linkini giriniz ')
headers= {'User-Agent' : 'my user agent(google)'}
def check_price():
page = requests.get(url,headers=headers)
soup =BeautifulSoup(page.content,'html.parser')
title = soup.find(id ='product-name').get_text().strip()
print(title)
span = soup.find(id ='offering-price')
content = span.attrs.get('content')
price = float(content)
print(price)
deger = float(input('Hangi fiyattan asagi dusmesini istiyorsunuz '))
if(price<deger):
send_mail(title,content)
def send_mail(title,content):
sender = 'mail_adresiniz@gmail.com'
reciever = input('Email Adresini Giriniz ')
try:
server = smtplib.SMTP('smtp.gmail.com',587)
server.ehlo()
server.starttls()
server.login(sender,'gmail app password')
subject = title + ' ' + 'Urun Fiyat Dustu. Yeni Fiyat :' + ' ' + content
body = 'Urune bu linkten gidebilirsin' + ' => ' +url
mailContent = f"To:{reciever}\nFrom:{sender}\nSubject:{subject}\n\n{body}"
server.sendmail(sender,reciever,mailContent)
print('Mail Gonderildi')
except smtplib.SMTPException as e:
print(e)
finally:
server.quit()
while(1):
check_price()
time.sleep(60*60)