Skip to content

Instantly share code, notes, and snippets.

@sterbon
Last active November 22, 2020 17:38
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 sterbon/8ad320507bbe3a4bf557d82001501833 to your computer and use it in GitHub Desktop.
Save sterbon/8ad320507bbe3a4bf557d82001501833 to your computer and use it in GitHub Desktop.
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