Home > Net >  Is there a way for me to use the output of this code and use the telegram api to alert me of a new e
Is there a way for me to use the output of this code and use the telegram api to alert me of a new e

Time:09-25

I'm trying to scrape recent releases of movies with the url. But i want to be notified of each new release. I also want to set a timer, let's say every two hours the script will check for a new movie release. If there's a new release it would be sent to my telegram bot. I have no idea on how to go about that yet.

from bs4 import BeautifulSoup
from urllib.request import Request, urlopen

req = Request("https://www.thenetnaija.com/videos/movies", headers={'User-Agent': 'XYZ/3.0'})
webpage = urlopen(req, timeout=10)
b4 = BeautifulSoup(webpage, "html.parser")
movie_list = b4.find_all("div", {"class" : "video-files"})
for allContainers in movie_list:
    filmName = allContainers.find('img').get('alt')
print(filmName)

CodePudding user response:

to send notification for you from telegram bot

1 - first talk to this bot: @userinfobot get the id

2 - get your bot token from @botfather

3 - send any message to your bot

(the above steps only one time)

4- make get request

https://api.telegram.org/bot{bot_token}/sendMessage?chat_id={chat_id}&text={notification_text}

  • Related