Skip to content

Commit 66d01f4

Browse files
Merge pull request HarshCasper#3 from HarshCasper/master
Getting updates
2 parents 977a59a + d8e0036 commit 66d01f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1101
-1
lines changed

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@
218218
"contributions": [
219219
"code"
220220
]
221+
},
222+
{
223+
"login": "bagofcodes",
224+
"name": "ANSHUMALI SHAW",
225+
"avatar_url": "https://avatars0.githubusercontent.com/u/37397899?v=4",
226+
"profile": "https://github.com/bagofcodes",
227+
"contributions": [
228+
"code",
229+
"doc"
230+
]
221231
}
222232
],
223233
"contributorsPerLine": 7,
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## Amazon Price Tracker ##
2+
- This script built in Python is an Amazon Price Tracker.
3+
- The user enters :
4+
- The URL of the product of which he would like the track the price of.
5+
- His/Her budget for the product.
6+
- His/Her Email credentials.
7+
- The script runs continuously and checks on the price of the product every 12 hours.
8+
- If the price of the product is equal to or below the user's budget, the user receives an email confirmation.
9+
- The price of the product is logged into a file named price_logger.txt every 12 hours.
10+
11+
## Working and Usage ##
12+
- The BeautifulSoup library is used to scrape the price of the product from the Amazon site.
13+
- On Amazon, the prices of products are either expressed as a range or as a single number.
14+
15+
![Image](single.png)
16+
17+
18+
![Image](range.png)
19+
20+
- If the budget is within the range, an email will be sent.
21+
- In the script, headers need to be used to make the get request to the Amazon site.
22+
- In place of headers, the user must replace it with the result of **my user agent** must be used instead.
23+
24+
![Image](myagent.png)
25+
26+
- The Email settings of the user must be configured to operate on less secure mode to facilitate the sending of emails.
27+
28+
![Image](lesssecure.png)
29+
30+
- After this, the script can be run.
31+
32+
![Image](mail.png)
33+
34+
![Image](email.png)
35+
36+
- Using this as an example
37+
38+
![Image](single.png)
39+
40+
- The user enters 700 rupees as the budget, as the price is lesser than the budget the following email is sent, else the program continues to run till the condition is satisfied.
41+
42+
![Image](confirm.png)
43+
44+
- The prices are also logged into the file price_logger.txt as shown, so the user will have an account of the changes the price underwent.
45+
46+
![Image](change.png)
1.93 KB
Loading
4.41 KB
Loading
2.27 KB
Loading
14.1 KB
Loading

Amazon-product-price-tracker/mail.png

25.8 KB
Loading
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/python
2+
3+
import smtplib
4+
5+
#The smtp module (Simple Mail Transfer Protocol) enables sending emails in python
6+
#The sender's email must be configured to less secure apps.
7+
#This configuration can be made on visiting account information.
8+
#Under the category security, less secure apps must turned on
9+
10+
def send_confirmation(sender_email, receiver_email, password, price_range):
11+
12+
#Subject of the Email
13+
subject = "Amazon product price "
14+
15+
if len(price_range) == 1:
16+
cost = "The cost of the product is" + str(price_range[0])
17+
else:
18+
cost = "The cost of the product is within the range " + str(price_range[0]) + " and " + str(price_range[1])
19+
20+
#Content of the email
21+
body_of_the_email = "Hello, This is to inform you that the price of the product you were looking for on Amazon is well-within your budget." + cost + " You can buy it right away."
22+
23+
content = "Subject: {}\n\n{}".format(subject, body_of_the_email)
24+
25+
#Specifications of the Email
26+
27+
server = smtplib.SMTP("smtp.gmail.com" , 587)
28+
29+
#Here the Gmail service is used, a different Email service can also be used
30+
#The port 587, across which the email is sent
31+
32+
server.starttls()
33+
server.login(sender_email, password)
34+
35+
#Login is authorised
36+
server.sendmail(sender_email, receiver_email, content)
37+
38+
#Email is sent, prints success on sending the email
39+
8.94 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The cost of the product is 649.0 at 2020-08-11 19:23:36.359383

0 commit comments

Comments
 (0)