File tree 5 files changed +43
-8
lines changed 5 files changed +43
-8
lines changed Original file line number Diff line number Diff line change 52
52
- [ Day 44] ( https://github.com/a092devs/100-days-of-python/tree/master/day044 ) - Intermediate CSS
53
53
- [ Day 45] ( https://github.com/a092devs/100-days-of-python/tree/master/day045 ) - Web Scraping with BeautifulSoup
54
54
- [ Day 46] ( https://github.com/a092devs/100-days-of-python/tree/master/day046 ) - Create a Spotify Playlist Using The Musical Time Machine
55
+ - [ Day 47] ( https://github.com/a092devs/100-days-of-python/tree/master/day047 ) - Create an Automated Amazon Price Tracker
55
56
56
57
## ⚙ Tools and Technologies Covered
57
58
- Python 3
Original file line number Diff line number Diff line change 4
4
import time
5
5
import smtplib
6
6
7
- MY_EMAIL = "my_email_was_here"
7
+ FROM_EMAIL = "my_email_was_here"
8
8
PASSWORD = "my_pass_was_here"
9
9
MY_LAT = 23.603900
10
10
MY_LONG = 87.117700
@@ -49,8 +49,8 @@ def is_night():
49
49
if is_iss_overhead () and is_night ():
50
50
with smtplib .SMTP ("smtp.mail.yahoo.com" , 587 ) as connection :
51
51
connection .starttls ()
52
- connection .login (MY_EMAIL , PASSWORD )
52
+ connection .login (FROM_EMAIL , PASSWORD )
53
53
connection .sendmail (
54
- from_addr = MY_EMAIL ,
54
+ from_addr = FROM_EMAIL ,
55
55
to_addrs = "a092devs@email.com" ,
56
56
msg = "Subject:Look Up👆🏼\n \n The ISS is above you in the sky!" .encode ("utf-8" ))
Original file line number Diff line number Diff line change 8
8
BOT_TOKEN = environ .get ("BOT_TOKEN" )
9
9
CHAT_ID = environ .get ("CHAT_ID" )
10
10
MAIL_PROVIDER_SMTP_ADDRESS = "smtp.mail.yahoo.com"
11
- MY_EMAIL = environ .get ("MY_EMAIL " )
12
- MY_PASSWORD = environ .get ("MY_PASSWORD " )
11
+ FROM_EMAIL = environ .get ("FROM_EMAIL " )
12
+ FROM_PASSWORD = environ .get ("FROM_PASSWORD " )
13
13
14
14
class NotificationManager :
15
15
def telegram_bot_send_text (self , bot_message ):
@@ -22,10 +22,10 @@ def telegram_bot_send_text(self, bot_message):
22
22
def send_emails (self , emails , message , google_flight_link ):
23
23
with smtplib .SMTP (MAIL_PROVIDER_SMTP_ADDRESS , 587 ) as connection :
24
24
connection .starttls ()
25
- connection .login (MY_EMAIL , MY_PASSWORD )
25
+ connection .login (FROM_EMAIL , FROM_PASSWORD )
26
26
for email in emails :
27
27
connection .sendmail (
28
- from_addr = MY_EMAIL ,
28
+ from_addr = FROM_EMAIL ,
29
29
to_addrs = email ,
30
30
msg = f"Subject:New Low Price Flight!\n \n { message } \n { google_flight_link } " .encode ('utf-8' )
31
31
)
Original file line number Diff line number Diff line change 9
9
CLIENT_ID = environ .get ("CLIENT_ID" )
10
10
CLIENT_SECRET = environ .get ("CLIENT_SECRET" )
11
11
12
- date = input ("Which day do you want to travel to? Type the date in this format: YYYY-MM-DD: " )
12
+ date = input ("Which day do you want to travel to? Type the date in this format YYYY-MM-DD: " )
13
13
14
14
URL = f"https://www.billboard.com/charts/hot-100/{ date } /"
15
15
response = requests .get (URL )
Original file line number Diff line number Diff line change
1
+ import requests
2
+ import smtplib
3
+ from bs4 import BeautifulSoup
4
+ from os import environ
5
+ from dotenv import load_dotenv
6
+
7
+ load_dotenv ('config.env' , override = True )
8
+
9
+ FROM_EMAIL = environ .get ("FROM_EMAIL" )
10
+ FROM_PASSWORD = environ .get ("FROM_PASSWORD" )
11
+ TO_EMAIL = environ .get ("TO_EMAIL" )
12
+
13
+ URL = "https://www.amazon.com/dp/B075CYMYK6"
14
+
15
+ http_headers = {
16
+ "Accept-Language" : "en-US,en;q=0.9" ,
17
+ "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.58"
18
+ }
19
+
20
+ response = requests .get (URL , headers = http_headers )
21
+ soup = BeautifulSoup (response .text , 'html.parser' )
22
+
23
+ price = float (soup .find (name = "span" , class_ = "a-offscreen" ).getText ()[1 :])
24
+ product_name = " " .join (soup .find (
25
+ name = "span" , class_ = "a-size-large product-title-word-break" ).getText ().split ())
26
+
27
+ if price < 10.00 :
28
+ with smtplib .SMTP ("smtp.mail.yahoo.com" , 587 ) as connection :
29
+ connection .starttls ()
30
+ connection .login (FROM_EMAIL , FROM_PASSWORD )
31
+ connection .sendmail (from_addr = FROM_EMAIL ,
32
+ to_addrs = TO_EMAIL ,
33
+ msg = f"Subject: Price Drop Alert!\n \n { product_name } is now available in ${ price } \n \n Visit: { URL } " .encode ('utf-8' )
34
+ )
You can’t perform that action at this time.
0 commit comments