Skip to content

Instantly share code, notes, and snippets.

@vininjr
Created March 22, 2020 19:09
Show Gist options
  • Save vininjr/10af941924eedd3062fbed65a22aeb30 to your computer and use it in GitHub Desktop.
Save vininjr/10af941924eedd3062fbed65a22aeb30 to your computer and use it in GitHub Desktop.
Script to check etufor consulta update. (ETUFOR CARTEIRIHA FORTLEZA CEARA)
#!/usr/bin/python3
import requests, time, smtplib, os
from bs4 import BeautifulSoup
from email.mime.text import MIMEText
cia_default = 'YOUR_CIA'
length = -1
while True:
url = "http://www.etufor.ce.gov.br/SUGEST_WEB/wbfRelFichaAluno.aspx?id=" + cia_default
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, "lxml")
result = [e.text.replace('\n','').replace('\t','').replace('\r','').strip() for e in soup.findAll('strong')]
if length == -1: length = len(result)
if len(result) == length:
pass
else:
fromaddr = 'YOUR_EMAIL'
toaddrs = ['OTHER_EMAIL_1', 'OTHER_EMAIL_2']
msg = MIMEText(str(result[-1]))
msg['Subject'] = 'Etufor carteirinha - Nova atualização'
msg['From'] = fromaddr
msg['To'] = ", ".join(toaddrs)
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromaddr, "YOUR_PASSWORD")
server.sendmail(fromaddr, toaddrs, msg.as_string())
server.quit()
length = -1
time.sleep(1800)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment