Skip to content

Commit 4cdf9c2

Browse files
authored
Merge pull request #3 from shubhmrj/amazon-price-tracker
completion of apt
2 parents 954d5ba + df6e189 commit 4cdf9c2

File tree

13 files changed

+367
-0
lines changed

13 files changed

+367
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ Output/
5151
*.png
5252
*.jpg
5353
*.xml
54+
55+
*.env

Amazon Price Tracker/main.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from bs4 import BeautifulSoup
2+
import requests
3+
import os
4+
import smtplib
5+
import datetime
6+
from dotenv import load_dotenv
7+
8+
load_dotenv()
9+
date=datetime.datetime.now().strftime("%d/%m/%Y")
10+
11+
# static url to get the price
12+
url="https://appbrewery.github.io/instant_pot/"
13+
14+
# live url to get the price which is dyanmaic hard to parse so i take the static url
15+
live_url = "https://www.amazon.com/dp/B075CYMYK6?psc=1&ref_=cm_sw_r_cp_ud_ct_FM9M699VKHTT47YD50Q6"
16+
17+
# ADD header for look my requests more realistics rather than ai generated
18+
# requests.get(url, params=None, headers=None, cookies=None, auth=None, timeout=None) this is params of requests
19+
20+
# header
21+
22+
header={
23+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
24+
"Accept-Encoding": "gzip, deflate, br, zstd",
25+
"Accept-Language": "en-US,en;q=0.9,hi;q=0.8",
26+
"Dnt": "1",
27+
"Priority": "u=0, i",
28+
"Sec-Ch-Ua": '"Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"',
29+
"Sec-Ch-Ua-Mobile": "?0",
30+
"Sec-Ch-Ua-Platform": "Windows",
31+
"Sec-Fetch-Dest": "document",
32+
"Sec-Fetch-Mode": "navigate",
33+
"Sec-Fetch-Site": "cross-site",
34+
"Sec-Fetch-User": "?1",
35+
"Upgrade-Insecure-Requests": "1",
36+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36",
37+
}
38+
39+
response=requests.get(url=live_url,headers=header)
40+
soup=BeautifulSoup(response.text,"html.parser")
41+
42+
# check whether what kind of requests i get
43+
print(soup.prettify()[:2000])
44+
45+
price=soup.find(class_="a-price-whole").get_text()
46+
47+
price_without_currency = price.split("$")[1]
48+
49+
price_as_float=float(price_without_currency)
50+
51+
print(price_as_float)
52+
53+
54+
# Send Email if price less than 100
55+
if price_as_float<100:
56+
my_email = os.getenv("EMAIL")
57+
password = os.getenv("PASSWORD")
58+
59+
with smtplib.SMTP("smtp.gmail.com",port=587) as connection:
60+
connection.starttls()
61+
connection.login(user=my_email,password=password)
62+
63+
connection.sendmail(
64+
from_addr=my_email,
65+
to_addrs="srnwda@gmail.com",
66+
msg=f"Subject:Amazon Price Alert\n\n{price}\n{live_url}\n at the time of {date}"
67+
)
68+
69+
# you can try with static becuase live might not run
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
whole

Automate Spotify Playlist/hint.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from bs4 import BeautifulSoup
2+
import requests
3+
4+
response = requests.get("https://appbrewery.github.io/news.ycombinator.com/")
5+
yc_web_page = response.text
6+
7+
soup = BeautifulSoup(yc_web_page, 'html.parser')
8+
9+
# Get all article links
10+
articles = soup.find_all(name='a', class_='storylink')
11+
12+
article_text = []
13+
article_url = []
14+
15+
for article in articles:
16+
text = article.get_text()
17+
article_text.append(text)
18+
url = article.get("href")
19+
article_url.append(url)
20+
21+
# Get upvotes
22+
article_upvote = [int(score.getText().split()[0]) for score in soup.find_all(name='span', class_="score")]
23+
24+
print(article_text)
25+
print(article_url)
26+
print(article_upvote)
27+
max_val=article_upvote.index(max(article_upvote))
28+
print("\n")
29+
print("Print the maximum score of article upvote")
30+
print(f"Article Text : {article_text[max_val]} , With url link : {article_url[max_val]} with total upvotes : {article_upvote[max_val]}")
31+
32+
# for split value of upvote
33+
# no_upvote = []
34+
#
35+
# for i in range(len(article_upvote)):
36+
# article_upvote1 = article_upvote[0].split(' ')[0]
37+
# no_upvote.append(article_upvote1)
38+
# print(no_upvote)

Automate Spotify Playlist/main.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from bs4 import BeautifulSoup
2+
import requests
3+
4+
5+
Date = input("Which year famous song playlist do you want to create ? Fomat YYYY-MM-DD : ")
6+
7+
# response = requests.get("https://www.billboard.com/charts/hot-100/2000-08-12/")
8+
#
9+
# yc_web_page = response.text
10+
#
11+
# soup = BeautifulSoup(yc_web_page, 'html.parser')
12+
13+
# Get all article links
14+
# articles = soup.find_all(name='a', id='title-of-a-story' , class_='c-title a-font-basic u-letter-spacing-0010 u-max-width-397 lrv-u-font-size-16 lrv-u-font-size-14@mobile-max u-line-height-22px u-word-spacing-0063 u-line-height-normal@mobile-max a-truncate-ellipsis-2line lrv-u-margin-b-025 lrv-u-margin-b-00@mobile-max')
15+
#
16+
# print(articles)
17+
18+
header = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0"}
19+
url = "https://www.billboard.com/charts/hot-100/" + Date
20+
response = requests.get(url=url, headers=header)
21+
22+
soup = BeautifulSoup(response.text, 'html.parser')
23+
song_names_spans = soup.select("li ul li h3")
24+
song_names = [song.getText().strip() for song in song_names_spans]
25+
print(song_names)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document Title</title>
7+
</head>
8+
<body>
9+
<h1>It's My Birthday!</h1>
10+
<h2>on the 10th feb</h2>
11+
<img src="https://raw.githubusercontent.com/appbrewery/webdev/main/birthday-cake3.4.jpeg" alt="purple birthday cake with candles" />
12+
<h3>What to bring:</h3>
13+
<ul>
14+
<li>Baloons (I love baloons)</li>
15+
<li>Cake (I'm really good at eating)</li>
16+
<li>An appetite (There will be lots of food)</li>
17+
</ul>
18+
<h3>This is where you need to go:</h3>
19+
<a href="https://www.google.com/maps/@35.7040744,139.5577317,3a,75y,289.6h,87.01t,0.72r/data=!3m6!1e1!3m4!1sgT28ssf0BB2LxZ63JNcL1w!2e0!7i13312!8i6656">Google map link</a>
20+
</body>
21+
</html>
22+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!-- This is one possible solution -->
2+
<h1>It's My Birthday!</h1>
3+
<h2>On the 12th May</h2>
4+
5+
<img src="https://raw.githubusercontent.com/appbrewery/webdev/main/birthday-cake3.4.jpeg"
6+
alt="purple birthday cake with candles" />
7+
8+
<h3>What to bring:</h3>
9+
<ul>
10+
<li>Baloons (I love baloons)</li>
11+
<li>Cake (I'm really good at eating)</li>
12+
<li>An appetite (There will be lots of food)</li>
13+
</ul>
14+
15+
<h3>This is where you need to go:</h3>
16+
<a
17+
href="https://www.google.com/maps/@35.7040744,139.5577317,3a,75y,289.6h,87.01t,0.72r/data=!3m6!1e1!3m4!1sgT28ssf0BB2LxZ63JNcL1w!2e0!7i13312!8i6656">Google
18+
map link</a>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document Title</title>
7+
</head>
8+
<body>
9+
<h1>Book</h1>
10+
<h2>Chapter 1</h2>
11+
<h3>Section 1</h3>
12+
<h3>Section 2</h3>
13+
<h2>Chapter 2</h2>
14+
<h3>Section 1</h3>
15+
<h4>Diagram 1</h4>
16+
<h2>Chapter 3</h2>
17+
<h3>Section 1</h3>
18+
<h3>Section 2</h3>
19+
</body>
20+
</html>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!-- Scroll 👇 to check the solution -->
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+
<h1>Book</h1>
29+
<h2>Chapter 1</h2>
30+
<h3>Section 1</h3>
31+
<h3>Section 2</h3>
32+
<h2>Chapter 2</h2>
33+
<h3>Section 1</h3>
34+
<h4>Diagram 1</h4>
35+
<h2>Chapter 3</h2>
36+
<h3>Section 1</h3>
37+
<h3>Section 2</h3>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<p style="font-size: medium; color: rgb(12, 108, 105);">First paragraph. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
2+
aliqua. Arcu cursus vitae congue mauris. In nisl nisi scelerisque eu ultrices vitae auctor eu augue. Nisi est sit amet
3+
facilisis magna. Diam sit amet nisl suscipit adipiscing bibendum est ultricies integer. Quis ipsum suspendisse ultrices
4+
gravida dictum fusce ut. Euismod elementum nisi quis eleifend. Habitant morbi tristique senectus et. Amet nisl suscipit
5+
adipiscing bibendum est ultricies integer. Viverra orci sagittis eu volutpat odio facilisis mauris sit. Nisi quis
6+
eleifend quam adipiscing. Neque convallis a cras semper auctor neque vitae. Magna fermentum iaculis eu non. Vivamus arcu
7+
felis bibendum ut tristique et. Justo nec ultrices dui sapien eget mi. In vitae turpis massa sed elementum tempus. Eu
8+
facilisis sed odio morbi quis commodo. Sagittis aliquam malesuada bibendum arcu vitae elementum curabitur vitae.</p>
9+
<hr/>
10+
<p>Second paragraph. Suscipit adipiscing bibendum est ultricies. Tortor aliquam nulla facilisi cras fermentum. Eget aliquet nibh praesent
11+
tristique magna. In hac habitasse platea dictumst vestibulum. Ornare quam viverra orci sagittis eu. Sit amet est
12+
placerat in. Proin fermentum leo vel orci porta non pulvinar neque laoreet. Turpis in eu mi bibendum neque egestas
13+
congue. Enim eu turpis egestas pretium aenean pharetra magna ac placerat. Ultrices sagittis orci a scelerisque purus
14+
semper eget duis at. Egestas egestas fringilla phasellus faucibus scelerisque eleifend donec pretium. Condimentum
15+
lacinia quis vel eros donec ac odio.</p>
16+
<br>
17+
<p>Third paragraph. Nisl purus in mollis nunc sed id semper risus. Ipsum a arcu cursus vitae congue mauris rhoncus aenean. Ridiculus mus
18+
mauris vitae ultricies leo integer malesuada nunc. In tellus integer feugiat scelerisque. Lectus mauris ultrices eros in
19+
cursus turpis massa. Sollicitudin ac orci phasellus egestas. Massa massa ultricies mi quis hendrerit dolor. Quam
20+
elementum pulvinar etiam non quam lacus suspendisse faucibus interdum. Iaculis nunc sed augue lacus viverra. Id ornare
21+
arcu odio ut sem nulla pharetra. Amet luctus venenatis lectus magna fringilla urna porttitor. Eu nisl nunc mi ipsum
22+
faucibus vitae aliquet nec ullamcorper. Nunc mattis enim ut tellus elementum sagittis. Mauris augue neque gravida in
23+
fermentum et sollicitudin. Pellentesque habitant morbi tristique senectus. Tristique senectus et netus et. Turpis
24+
egestas sed tempus urna et pharetra pharetra. Feugiat vivamus at augue eget arcu dictum varius duis at. Lacus sed
25+
viverra tellus in hac habitasse platea dictumst vestibulum. Nisl condimentum id venenatis a condimentum vitae sapien.</p>

0 commit comments

Comments
 (0)