-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
57 lines (46 loc) · 1.66 KB
/
Copy pathmain.py
File metadata and controls
57 lines (46 loc) · 1.66 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
47
48
49
50
51
52
53
54
55
56
57
from amazon_bot import amazon_bot as ab
import smtplib
def main():
with open('password.txt') as f:
password = f.read()
with open('email.txt') as f:
email = f.read()
# works with https://www.amazon.com/AmazonBasics-Volt-Performance-Alkaline-Batteries/dp/B081FFR91C/ref=sr_1_11?keywords=aaa+batteries&qid=1637273963&sr=8-11
# need some error handling to work for every url, some pages have a checkout pop-up, others have a subscription
# option rather than one time purchase, both of these cases break the program
url = input("Enter a Amazon Product Url: ")
bot = ab(email, password, url)
bot.add_product_to_cart()
bot.login_amazon()
bot.shipping()
# can't get payment switching working yet
# bot.payment()
bot.checkout()
# send an email when it adds to cart
# not working yet, but close...
# with open('email_password.txt') as f:
# email_pass = f.read()
# gmail_user = email
# gmail_password = email_pass
# sent_from = gmail_user
# to = email
# subject = 'Item Added to Your Amazon Cart'
# body = f'Item added to your cart! Go to this link now to checkout! ({bot.get_url()})'
# email_text = """\
# From: %s
# To: %s
# Subject: %s
# %s
# """ % (sent_from, to, subject, body)
# try:
# server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
# server.ehlo()
# server.login(gmail_user, gmail_password)
# server.sendmail(sent_from, to, email_text)
# server.close()
# print('Email sent!')
# except:
# print('Something went wrong...')
# finally close the webdriver session
bot.close_session()
main()