Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aa0ed09

Browse files
Merge pull request avinashkranjan#4 from avinashkranjan/master
Update fork
2 parents dd10f4e + 25b1fbd commit aa0ed09

File tree

26 files changed

+804
-62
lines changed

26 files changed

+804
-62
lines changed

‎.all-contributorsrc‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,36 @@
9494
"code",
9595
"doc"
9696
]
97+
},
98+
{
99+
"login": "vivax3794",
100+
"name": "vivax",
101+
"avatar_url": "https://avatars2.githubusercontent.com/u/51753506?v=4",
102+
"profile": "https://github.com/vivax3794",
103+
"contributions": [
104+
"code",
105+
"doc"
106+
]
107+
},
108+
{
109+
"login": "SethWalkeroo",
110+
"name": "Seth Walker",
111+
"avatar_url": "https://avatars0.githubusercontent.com/u/16292617?v=4",
112+
"profile": "https://github.com/SethWalkeroo",
113+
"contributions": [
114+
"code",
115+
"doc"
116+
]
117+
},
118+
{
119+
"login": "sarthak1905",
120+
"name": "sarthak1905",
121+
"avatar_url": "https://avatars3.githubusercontent.com/u/61883822?v=4",
122+
"profile": "https://www.linkedin.com/in/sarthak-saxena-b3a0001b8/",
123+
"contributions": [
124+
"code",
125+
"doc"
126+
]
97127
}
98128
],
99129
"contributorsPerLine": 7,

‎Amazon Price Alert/README.md‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Amazon prices keep fluctuating- Let's scrape them!
2+
3+
C3PO is a web-scraper built on BeautifulSoup that alerts you when the price of an amazon prduct falls within your budget! Currently in development.
4+
5+
## What is the use?
6+
7+
Nothing is worse than seeing the price drop of a product you just bought on Amazon drop 2 days after you bought it. Wouldn't it be amazing if a python script could just
8+
ask you your budget and the product link and then notify you when the product price drops below that? This is exactly what this script does!
9+
10+
## How to use
11+
12+
- Simply copy the link of the product and your budget that's it!
13+
- Paste the link when the program requests you to
14+
- Enter budget for the product(without currency symbol)
15+
- Select frequency to check prices
16+
- Keep the script running in the background
17+
The scraper will do the rest for you and notify you when the price is in your budget.
18+
However, it is to be kept in mind that the sender email ID and password has been stored in os variables in the script. Therefore, wherever you see the imports of
19+
'DEVELOPER_EMAIL' and 'DEVELOPER_PASS', be sure to replace them with the email ID you wish to recieve the notification from.
20+
21+
### Side Note
22+
23+
Do remember to install the dependencies in the requirements.txt file!
24+
25+
## Modules used (available in requirements.txt)
26+
27+
- requests_html
28+
- BeautifulSoup
29+
30+
## Development Status
31+
32+
This scrapper is complete. A future version may have emails sent via a server.
33+
34+
### Developed by [Sarthak Saxena](https://github.com/sarthak1905)

‎Amazon Price Alert/amazon_scraper.py‎

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Developed and maintained by https://github.com/sarthak1905
2+
from bs4 import BeautifulSoup
3+
from requests_html import HTMLSession
4+
import os
5+
import time
6+
import smtplib
7+
import ssl
8+
9+
10+
class Scraper:
11+
12+
# Initializes the scraper C3PO
13+
def __init__(self, url, budget, u_email):
14+
15+
# Attributes about product
16+
self.url = url
17+
self.budget = budget
18+
19+
# Setting user email
20+
self.u_email = u_email
21+
22+
# Attributes about scraping
23+
self.session = HTMLSession()
24+
self.webpage = self.session.get(self.url).content
25+
self.parser = 'lxml'
26+
self.soup = BeautifulSoup(self.webpage, self.parser)
27+
28+
# Prints the object
29+
def __str__(self):
30+
return self.soup.prettify()
31+
32+
# Stores the title of the product
33+
def get_title(self):
34+
temp_title = self.soup.find('span', id='productTitle').text.strip()
35+
temp_list_title = []
36+
for x in temp_title:
37+
if x == '(':
38+
break
39+
temp_list_title.append(x)
40+
self.product_title = ''.join(temp_list_title)
41+
return self.product_title
42+
43+
# Stores the price of the product after filtering the string and
44+
# converting it to an integer
45+
def get_price(self):
46+
price_raw = self.soup.find(
47+
'span', id='priceblock_ourprice').text.strip()
48+
price_filtered = price_raw[2:len(price_raw) - 3]
49+
self.product_price = int(
50+
''.join([x for x in price_filtered if x != ',']))
51+
return
52+
53+
# Prints product title
54+
def print_title(self):
55+
print(self.product_title)
56+
return
57+
58+
# Prints product price
59+
def print_price(self):
60+
print(self.product_price)
61+
return
62+
63+
# Checks if the price of the product is below the budget
64+
def is_below_budget(self):
65+
if self.product_price <= self.budget:
66+
return True
67+
else:
68+
return False
69+
70+
# Runs the scraper
71+
def run(self):
72+
73+
self.get_title()
74+
self.get_price()
75+
self.alert = self.is_below_budget()
76+
self.status = False
77+
if self.alert:
78+
self.status = self.send_email()
79+
return self.status
80+
81+
# Sends an email when the condition is satisfied. Under testing!
82+
def send_email(self):
83+
84+
# Attributes for email sending
85+
port = 587
86+
smtp_server = 'smtp.gmail.com'
87+
self.email = str(os.environ.get('DEVELOPER_MAIL'))
88+
self.app_pw = str(os.environ.get('DEVELOPER_PASS'))
89+
90+
# Message details
91+
subject = f'The price of {self.get_title()} is within your budget!'
92+
93+
body_start = """Hey there!\n
94+
The price is now within your budget. Here is the link, buy it now!\n"""
95+
body_mid = self.url
96+
body_end = '\n\nRegards\nYour friendly neighbourhood programmer'
97+
body = str(body_start) + str(body_mid) + str(body_end)
98+
99+
message = f"Subject: {subject}\n\n{body}"
100+
101+
# Establishing server
102+
context = ssl.create_default_context()
103+
self.server = smtplib.SMTP(smtp_server, port)
104+
105+
# Mail sending
106+
self.server.ehlo()
107+
self.server.starttls(context=context)
108+
self.server.ehlo()
109+
self.server.login(self.email, self.app_pw)
110+
111+
self.server.sendmail(self.email, self.u_email, message)
112+
113+
print("Email sent successfully!")
114+
self.server.quit()
115+
return True
116+
117+
118+
def main():
119+
url = input(
120+
"Paste the link of the Amazon product:")
121+
budget = int(input("Enter you budget price:"))
122+
u_email = input("Enter your email:")
123+
inp_str = ("How frequuently would you like to check the price?"
124+
"\n1.Every hour\n2.Every 3 hours\n3.Every 6 hours"
125+
"\nEnter your choice(default is 6 hours):")
126+
time_choice = int(input(inp_str))
127+
if time_choice == 1:
128+
time_delay = 60 * 60
129+
elif time_choice == 2:
130+
time_delay = 3 * 60 * 60
131+
else:
132+
time_delay = 6 * 60 * 60
133+
msg = (
134+
"Great! Now just sit back and relax."
135+
"Minimize this program and be sure "
136+
"that it is running.\nAdditionally, ensure that there"
137+
"is stable internet connection "
138+
"during the time this program runs.\nIf the price of the "
139+
"product falls within your budget, "
140+
"you will recieve an email regarding the same and this"
141+
"program will auto-close.\nThank you for using "
142+
"C3PO scraper! Beep-bop bop-beep.")
143+
print(msg)
144+
c3po = Scraper(url, budget, u_email)
145+
while True:
146+
if c3po.run():
147+
break
148+
time.sleep(time_delay)
149+
150+
151+
if __name__ == '__main__':
152+
main()

‎Amazon Price Alert/requirements.txt‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
appdirs==1.4.4
2+
beautifulsoup4==4.9.1
3+
bs4==0.0.1
4+
certifi==2020年6月20日
5+
chardet==3.0.4
6+
cssselect==1.1.0
7+
fake-useragent==0.1.11
8+
idna==2.10
9+
lxml==4.5.2
10+
parse==1.18.0
11+
pyee==7.0.4
12+
pyppeteer==0.2.2
13+
pyquery==1.4.1
14+
requests==2.24.0
15+
requests-html==0.10.0
16+
six==1.15.0
17+
soupsieve==2.0.1
18+
tqdm==4.49.0
19+
urllib3==1.25.10
20+
w3lib==1.22.0
21+
websockets==8.1

‎Amazon Price Alert/screenshot.png‎

24.5 KB
Loading[フレーム]
File renamed without changes.
Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
1-
from tkinter import*
2-
3-
root = Tk()
4-
root.geometry("1350x650+0+0")
5-
root.resizable(0,0)
6-
root.title("BMI CALCULATOR")
7-
8-
def BMI_Cal():
9-
Bheight = float(var2.get())
10-
Bweight = float(var1.get())
11-
BMI = str('%.2f' %(Bweight / (Bheight * Bheight)))
12-
labelBMIResult.config(text = BMI)
13-
14-
15-
var1 = DoubleVar()
16-
var2 = DoubleVar()
17-
18-
Tops = Frame(root, width = 1350, height = 50, bd = 8, relief = "raise")
19-
Tops.pack(side = TOP)
20-
21-
f1 = Frame(root, width = 600, height = 600, bd = 8, relief = "raise")
22-
f1.pack(side = LEFT)
23-
24-
f2 = Frame(root, width = 300, height = 700, bd = 8, relief = "raise")
25-
f2.pack(side = RIGHT)
26-
27-
f1a = Frame(f1, width = 600, height = 200, bd = 20, relief = "raise")
28-
f1a.pack(side = TOP)
29-
f1b = Frame(f1, width = 600, height = 600, bd = 20, relief = 'raise')
30-
f1b.pack(side=TOP)
31-
32-
label1Title = Label(Tops, text = " BODY MASS INDEX ", padx = 16, pady = 16, bd = 16, fg = '#000000', font = ("arial", 54, 'bold'), bg = "powder blue", relief = 'raise', width = 32, height = 1)
33-
label1Title.pack()
34-
35-
labelweight = Label(f1a, text = "Select Weight in Kilograms", font =('arial', 20, 'bold'), bd = 20).grid(row = 0, column = 0)
36-
Bodyweight = Scale(f1a, variable = var1, from_ = 1, to = 500, length = 880, tickinterval = 30, orient = HORIZONTAL)
37-
Bodyweight.grid(row = 1, column = 0)
38-
39-
labelheight = Label(f1b, text = "Enter Height in Meters Square", font =('arial', 20, 'bold'), bd = 20).grid(row = 0, column = 0)
40-
textheight = Entry(f1b, textvariable = var2, font = ('arial', 16, 'bold'), bd = 16, width = 22, justify = 'center')
41-
textheight.grid(row = 1, column = 0)
42-
43-
labelBMIResult = Label(f1b, padx = 16, pady = 16, bd = 16, fg = '#000000', font = ('arial', 30, 'bold'), bg = 'sky blue', relief = 'sunk', width = 34, height = 1)
44-
labelBMIResult.grid(row = 2, column = 0)
45-
46-
labelBMITable = Label(f2, font = ("arial", 20, 'bold'), text = 'BMI Table').grid(row = 0, column = 0)
47-
txtlabelBMITable = Text(f2, height = 12, width = 38, bd = 16, font = ("arial", 12, 'bold'))
48-
txtlabelBMITable.grid(row = 1, column = 0)
49-
50-
txtlabelBMITable.insert(END, 'Meaning \t\t' + "BMI \n\n")
51-
txtlabelBMITable.insert(END, 'Normal weight \t\t' + "19-24 \n\n")
52-
txtlabelBMITable.insert(END, 'Overwight \t\t' + "25-29,9 \n\n")
53-
txtlabelBMITable.insert(END, 'Obesity level I \t\t' + "30-34, 9 \n\n")
54-
txtlabelBMITable.insert(END, 'Obesity level II \t\t' + "35-39, 9\n\n")
55-
txtlabelBMITable.insert(END, 'Obesity level III \t\t' + ">= 40\n\n")
56-
57-
btnBMI = Button(f2, text = "Click to \nCheck Your \nBMI", padx = 8, pady = 8, bd = 12, width = 21, font = ("arial", 20, 'bold'), height = 3, command = BMI_Cal)
58-
btnBMI.grid(row = 2, column = 0)
59-
60-
root.mainloop()
61-
1+
from tkinter import*
2+
3+
root = Tk()
4+
root.geometry("1350x650+0+0")
5+
root.resizable(0,0)
6+
root.title("BMI CALCULATOR")
7+
8+
def BMI_Cal():
9+
Bheight = float(var2.get())
10+
Bweight = float(var1.get())
11+
BMI = str('%.2f' %(Bweight / (Bheight * Bheight)))
12+
labelBMIResult.config(text = BMI)
13+
14+
15+
var1 = DoubleVar()
16+
var2 = DoubleVar()
17+
18+
Tops = Frame(root, width = 1350, height = 50, bd = 8, relief = "raise")
19+
Tops.pack(side = TOP)
20+
21+
f1 = Frame(root, width = 600, height = 600, bd = 8, relief = "raise")
22+
f1.pack(side = LEFT)
23+
24+
f2 = Frame(root, width = 300, height = 700, bd = 8, relief = "raise")
25+
f2.pack(side = RIGHT)
26+
27+
f1a = Frame(f1, width = 600, height = 200, bd = 20, relief = "raise")
28+
f1a.pack(side = TOP)
29+
f1b = Frame(f1, width = 600, height = 600, bd = 20, relief = 'raise')
30+
f1b.pack(side=TOP)
31+
32+
label1Title = Label(Tops, text = " BODY MASS INDEX ", padx = 16, pady = 16, bd = 16, fg = '#000000', font = ("arial", 54, 'bold'), bg = "powder blue", relief = 'raise', width = 32, height = 1)
33+
label1Title.pack()
34+
35+
labelweight = Label(f1a, text = "Select Weight in Kilograms", font =('arial', 20, 'bold'), bd = 20).grid(row = 0, column = 0)
36+
Bodyweight = Scale(f1a, variable = var1, from_ = 1, to = 500, length = 880, tickinterval = 30, orient = HORIZONTAL)
37+
Bodyweight.grid(row = 1, column = 0)
38+
39+
labelheight = Label(f1b, text = "Enter Height in Meters Square", font =('arial', 20, 'bold'), bd = 20).grid(row = 0, column = 0)
40+
textheight = Entry(f1b, textvariable = var2, font = ('arial', 16, 'bold'), bd = 16, width = 22, justify = 'center')
41+
textheight.grid(row = 1, column = 0)
42+
43+
labelBMIResult = Label(f1b, padx = 16, pady = 16, bd = 16, fg = '#000000', font = ('arial', 30, 'bold'), bg = 'sky blue', relief = 'sunk', width = 34, height = 1)
44+
labelBMIResult.grid(row = 2, column = 0)
45+
46+
labelBMITable = Label(f2, font = ("arial", 20, 'bold'), text = 'BMI Table').grid(row = 0, column = 0)
47+
txtlabelBMITable = Text(f2, height = 12, width = 38, bd = 16, font = ("arial", 12, 'bold'))
48+
txtlabelBMITable.grid(row = 1, column = 0)
49+
50+
txtlabelBMITable.insert(END, 'Meaning \t\t' + "BMI \n\n")
51+
txtlabelBMITable.insert(END, 'Normal weight \t\t' + "19-24 \n\n")
52+
txtlabelBMITable.insert(END, 'Overwight \t\t' + "25-29,9 \n\n")
53+
txtlabelBMITable.insert(END, 'Obesity level I \t\t' + "30-34, 9 \n\n")
54+
txtlabelBMITable.insert(END, 'Obesity level II \t\t' + "35-39, 9\n\n")
55+
txtlabelBMITable.insert(END, 'Obesity level III \t\t' + ">= 40\n\n")
56+
57+
btnBMI = Button(f2, text = "Click to \nCheck Your \nBMI", padx = 8, pady = 8, bd = 12, width = 21, font = ("arial", 20, 'bold'), height = 3, command = BMI_Cal)
58+
btnBMI.grid(row = 2, column = 0)
59+
60+
root.mainloop()
61+
File renamed without changes.
File renamed without changes.

‎DiscordBot/README.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# How To Run
2+
follow this guide to get a token and setup a bot account: <https://www.writebots.com/discord-bot-token/>
3+
4+
Then insert your token at the top of the file.
5+
6+
Make sure you have discord.py installed:
7+
```bash
8+
pip install discord
9+
```
10+
11+
Then just run the bot using python:
12+
```bash
13+
python bot.py
14+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /