Skip to content

Instantly share code, notes, and snippets.

@SubhrajyotiSen
Last active January 6, 2021 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SubhrajyotiSen/a6e52a1a33b31350858d99fa56133cc6 to your computer and use it in GitHub Desktop.
Save SubhrajyotiSen/a6e52a1a33b31350858d99fa56133cc6 to your computer and use it in GitHub Desktop.
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