3
3
import time
4
4
import smtplib
5
5
6
- #header = {
7
- # "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
8
- #}
6
+ #header = {
7
+ # "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"
8
+ #}
9
9
10
- #Url = "https://www.amazon.in/Apple-AirPods-Wireless-Charging-Case/dp/B07QDRYVCZ/ref=sr_1_1_sspa?crid=2O0YQXVBL4T86&dchild=1&keywords=airpods&qid=1601031081&sprefix=airpod%2Caps%2C615&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUFPVUpPNUNIQUE1RUUmZW5jcnlwdGVkSWQ9QTAxNzI3NjJPNlg3OTJFSTVSOE8mZW5jcnlwdGVkQWRJZD1BMDg1MTYzNjJSRUw4VFVKQzQ1TDkmd2lkZ2V0TmFtZT1zcF9hdGYmYWN0aW9uPWNsaWNrUmVkaXJlY3QmZG9Ob3RMb2dDbGljaz10cnVl"
10
+ #Url = "https://www.amazon.in/Apple-AirPods-Wireless-Charging-Case/dp/B07QDRYVCZ/ref=sr_1_1_sspa?crid=2O0YQXVBL4T86&dchild=1&keywords=airpods&qid=1601031081&sprefix=airpod%2Caps%2C615&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUFPVUpPNUNIQUE1RUUmZW5jcnlwdGVkSWQ9QTAxNzI3NjJPNlg3OTJFSTVSOE8mZW5jcnlwdGVkQWRJZD1BMDg1MTYzNjJSRUw4VFVKQzQ1TDkmd2lkZ2V0TmFtZT1zcF9hdGYmYWN0aW9uPWNsaWNrUmVkaXJlY3QmZG9Ob3RMb2dDbGljaz10cnVl"
11
11
12
12
# get your browser information by searching "my user agent"
13
13
user_agent = input ("Enter your User-Agent string here\n " )
19
19
20
20
page = requests .get (Url , headers = headers )
21
21
soup = BeautifulSoup (page .content , "html.parser" )
22
+
23
+
22
24
# print(soup)
23
25
24
26
@@ -39,20 +41,26 @@ def mail_sending(mail_id, title, password):
39
41
def check_price ():
40
42
title = soup .find (id = "productTitle" ).get_text ().strip ()
41
43
try :
42
- price = soup .find (id = "priceblock_ourprice_row" ).get_text ().strip ()[:20 ].replace ('₹' , '' ).replace (' ' , '' ).replace (
43
- 'Price:' , '' ).replace ('\n ' , '' ).replace ('\xa0 ' , '' ).replace (',' , '' ).replace ('Fu' ,'' )
44
-
45
- price = soup .find (id = "priceblock_dealprice" ).get_text ().strip ()[:20 ].replace ('₹' , '' ).replace (' ' , '' ).replace (
46
- 'Price:' , '' ).replace ('\n ' , '' ).replace ('\xa0 ' , '' ).replace (',' , '' ).replace ('Fu' ,'' )
47
-
48
- price = soup .find (id = "priceblock_ourprice" ).get_text ().strip ()[:20 ].replace ('₹' , '' ).replace (' ' , '' ).replace (
44
+ price = soup .find (id = "priceblock_ourprice_row" ).get_text ().strip ()[:20 ].replace ('₹' , '' ).replace (' ' ,
45
+ '' ).replace (
49
46
'Price:' , '' ).replace ('\n ' , '' ).replace ('\xa0 ' , '' ).replace (',' , '' ).replace ('Fu' , '' )
50
47
51
- price = soup .find (id = "priceblock_ourprice_lbl" ).get_text ().strip ()[:20 ].replace ('₹' , '' ).replace (' ' , '' ).replace (
52
- 'Price:' , '' ).replace ('\n ' , '' ).replace ('\xa0 ' , '' ).replace (',' , '' ).replace ('Fu' , '' )
53
-
54
- except AttributeError :
55
- pass
48
+ except :
49
+ try :
50
+ price = soup .find (id = "priceblock_dealprice" ).get_text ().strip ()[:20 ].replace ('₹' , '' ).replace (' ' ,
51
+ '' ).replace (
52
+ 'Price:' , '' ).replace ('\n ' , '' ).replace ('\xa0 ' , '' ).replace (',' , '' ).replace ('Fu' , '' )
53
+
54
+ except :
55
+ try :
56
+ price = soup .find (id = "priceblock_ourprice" ).get_text ().strip ()[:20 ].replace ('₹' , '' ).replace (' ' ,
57
+ '' ).replace (
58
+ 'Price:' , '' ).replace ('\n ' , '' ).replace ('\xa0 ' , '' ).replace (',' , '' ).replace ('Fu' , '' )
59
+
60
+ except :
61
+ price = soup .find (id = "priceblock_ourprice_lbl" ).get_text ().strip ()[:20 ].replace ('₹' , '' ).replace (' ' ,
62
+ '' ).replace (
63
+ 'Price:' , '' ).replace ('\n ' , '' ).replace ('\xa0 ' , '' ).replace (',' , '' ).replace ('Fu' , '' )
56
64
57
65
fixed_price = float (price )
58
66
print (title )
0 commit comments