-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
40 lines (32 loc) · 1.03 KB
/
main.py
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
from selenium import webdriver
from bs4 import BeautifulSoup
from smtplib import SMTP as SMTP
import schedule
import time
def getSizes():
driver = webdriver.Chrome('./chromedriver')
driver.get("https://tjmaxx.tjx.com/store/jump/product/Western-Toe-Heel-Booties/1000263516?colorId=NS2857147&pos=1:1&Ntt=western%20toe%20heel%20booties")
html = driver.page_source
soup = BeautifulSoup(html, "html.parser")
for size in soup.find_all("span", class_="option-name"):
if size.contents[0] == '8':
sendEmail()
driver.quit()
def sendEmail():
user = "<YOUR_EMAIL>"
pswrd = "<YOUR_PASSWORD>"
message = "Your size is available! Go get those boots."
conn = SMTP(host="smtp.gmail.com", port=587)
conn.ehlo()
conn.starttls()
conn.ehlo()
sender = user
recipient = user
conn.login(user,pswrd)
conn.sendmail(sender,recipient,message)
print("Email sent!")
conn.close()
schedule.every().day.at("07:00").do(getSizes)
while True:
schedule.run_pending()
time.sleep(1)