Last active
November 22, 2020 17:38
-
-
Save sterbon/8ad320507bbe3a4bf557d82001501833 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 urllib.request | |
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
from re import search | |
def send_email(mail_content, receiver_address): | |
sender_address = 'sender@gmail.com' | |
sender_pass = 'senderpass' | |
message = MIMEMultipart() | |
message['From'] = sender_address | |
message['To'] = receiver_address | |
message['Subject'] = 'Your result for B.tech 8th Sem is ready!' | |
message.attach(MIMEText(mail_content, 'plain')) | |
session = smtplib.SMTP('smtp.gmail.com', 587) | |
session.starttls() | |
session.login(sender_address, sender_pass) | |
text = message.as_string() | |
session.sendmail(sender_address, receiver_address, text) | |
session.quit() | |
print('Mail Sent') | |
def is_my_result(link): | |
substring1 = "b.tech" | |
substring2 = "8th" | |
if search(substring1, link.lower()) and search(substring2, link.lower()): | |
send_email('Result is here, click this link to download http://ggsipu.ac.in/ExamResults' + link, 'receiver@gmail.com') | |
else: | |
pass | |
resp = urllib.request.urlopen("http://ggsipu.ac.in/ExamResults/ExamResultsmain.htm") | |
soup = BeautifulSoup(resp, 'html.parser', from_encoding=resp.info().get_param('charset')) | |
for td in soup.find_all('td', limit = 12): | |
for link in td.find_all('a', href=True): | |
oplink = link['href'] | |
print(oplink) | |
is_my_result(oplink) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment