· 5 years ago · May 08, 2020, 01:36 PM
1from bs4 import BeautifulSoup as BS
2import requests
3import datetime
4
5url = "https://www.moneycontrol.com/india/stockpricequote/refineries/relianceindustries/RI"
6API_KEY = "API KEY HERE"
7mobile_no = "MOBILE NUMBER HERE"
8threshold = 1600
9
10while True:
11 r = requests.get(url)
12 d = datetime.datetime.now()
13 soup = BS(r.text, features="html.parser")
14 #li = soup.findAll("span", {"class": "span_price_wrap stprh grnclr"})
15 li = (soup.findAll("span", {"class": "span_price_wrap stprh grn_hilight grnclr"}))
16 if len(li) == 0:
17 print("NOT HIGHLIGHTED")
18 else:
19 print("₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹₹")
20 print("|")
21 print("-->", d.strftime("%B %d, %Y | %I:%M:%S %p"))
22 print("|")
23 print("-->BSE: ", li[0].text)
24 print("|")
25 print("-->NSE: ", li[1].text)
26 print("|")
27 if min(float(li[0].text), float(li[1].text)) <= threshold:
28 message_string = "\nCURRENT PRICE OF RELIANCE INDUSTRIES STOCK IS " + str(min(float(li[0].text), float(li[1].text))) + "\nHURRY UP!!!" + "\nPrice at " + d.strftime("%B %d, %Y | %I:%M:%S %p")
29 message_url = "https://www.fast2sms.com/dev/bulk?authorization=" + API_KEY + "&sender_id=FSTSMS&message=" + message_string + "&language=english&route=p&numbers=" + mobile_no + "&flash=0"
30 requests.get(message_url)
31 print("MESSAGE SENT")
32 break
33 print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n")