import requests
import telepot
from bs4 import BeautifulSoup
login_url = 'https://charaka.wbuhs.ac.in/home/authenticate'
result_url = 'https://charaka.wbuhs.ac.in/ExamEnrollment/GetMarksStatementDetails?ScheduleID=669'
telegram_token = '5334780815:AAHvvq9c26PIlumiMtzmkYp7R2B3FKkFQKw'
telegram_receiver_id = 614975195
payload = {
'UserName': '',
'Password': '',
'LoginType': '3'
}
def get_message(marks, grade):
marks = int(marks)
if marks > 16:
message = f'Congrats Butu! You have passed ❤ :) Pedia Marks⬆📈' + f'\n\nNew score: {marks}, Grade: {grade}' + '\n\nYipee! My butu is now a doctor 👩⚕️'
elif marks == 13:
message = f'Marks still same😪, Please wait for the next update ⏱' + f'\n\nMarks: {marks}, Grade: {grade}'
else:
message = f'Marks: {marks}, Grade: {grade}'
return message
def send_telegram_message(message):
bot = telepot.Bot(telegram_token)
bot.sendMessage(telegram_receiver_id, message)
with requests.session() as s:
s.post(login_url, data=payload)
r = s.get(result_url)
soup = BeautifulSoup(r.content, 'html.parser')
tds = soup.find_all("td", text="Paediatrics (including Neonatology)")
# .find_next_sibling("td")
for i, td in enumerate(tds):
td1 = td.find_next_sibling("td")
td2 = td1.find_next_sibling("td")
td3 = td2.find_next_sibling("td")
td4 = td3.find_next_sibling("td")
if i == 2:
pedia_marks = td4.text
if i == 8:
pedia_grade = td4.text
print(td3.text)
message = get_message(pedia_marks, pedia_grade)
send_telegram_message(message)