Last active
August 29, 2015 14:09
-
-
Save ga2arch/59c49a321d59f4205153 to your computer and use it in GitHub Desktop.
Prendere gli appelli dal sito della bicocca
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
# sudo pip install requests, beautifulsoup4, blessings | |
import requests | |
from bs4 import BeautifulSoup as BS | |
from blessings import Terminal | |
t = Terminal() | |
username = <username> | |
password = <password> | |
login_url = 'https://s3w.si.unimib.it/esse3/auth/Logon.do' | |
appelli_url = 'https://s3w.si.unimib.it/esse3/auth/studente/Appelli/Appelli.do' | |
r = requests.get(login_url, auth=(username, password)) | |
r = requests.get(appelli_url, auth=(username, password), cookies=r.cookies) | |
bs = BS(r.text) | |
table = bs.find('table', class_='detail_table') | |
raw_appelli = table.find_all('tr')[1:] | |
for r_a in raw_appelli: | |
data = r_a.find_all('td') | |
name = data[1].text | |
date = data[2].text | |
iscrizione = data[3].contents | |
iscrizione[1]= iscrizione[1].text | |
iscrizione = ' - '.join(iscrizione) | |
notes = data[4].text | |
session = data[5].contents | |
if len(session) > 2: | |
session[1]= session[1].text | |
session = ' - '.join(session) | |
else: | |
session = data[5].text | |
elems = (name, date, iscrizione, notes, session) | |
print "{t.bold}{t.black}*{t.normal} {t.bold}{t.yellow}%s {t.red}%s {t.green}%s {t.blue}%s %s{t.normal}".format(t=t) % elems |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment