Last active
January 6, 2021 15:40
-
-
Save SubhrajyotiSen/a6e52a1a33b31350858d99fa56133cc6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
import urllib3 | |
def main(): | |
url = "https://rptechindia.in/nvidia-geforce-rtx-3070.html" | |
hdr = {'User-Agent': | |
('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 ' | |
'(KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11'), | |
'Accept': | |
('text/html,application/xhtml+xml,' | |
'application/xml;q=0.9,*/*;q=0.8'), | |
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', | |
'Accept-Encoding': 'none', | |
'Accept-Language': 'en-US,en;q=0.8', | |
'Connection': 'keep-alive'} | |
http = urllib3.PoolManager() | |
response = http.request('GET', url, hdr) | |
soup = BeautifulSoup(response.data, 'html.parser') | |
span_text = soup.find_all('span', {'class' :'rs2'})[0].text | |
if 'Out of stock' not in span_text: | |
text = "In stock. BUY! BUY! BUY!" | |
chat_id = YOUR_CHAT_ID | |
bot_secret = YOUR_BOT_SECRET | |
data = {'text': f"{text}", 'chat_id': f"{chat_id}"} | |
requests.post(f"https://api.telegram.org/bot{bot_secret}/sendMessage", data = data) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment