Created
September 5, 2012 21:38
-
-
Save SalemHarrache/3645300 to your computer and use it in GitHub Desktop.
Adeweb authentification
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
# install : sudo easy_install requests | |
# run : python adeweb.py | |
import re | |
import requests | |
def get_url_img(identifier, week, treeid): | |
url_img = 'http://adeweb.univ-lyon1.fr/ade/imageEt?identifier=' \ | |
+ identifier + '&projectId=25&idPianoDay=0%2C1%2C2%2' \ | |
'C3%2C4&width=1200&height=800&lunchName=REPAS&displa' \ | |
'yMode=1057855&showLoad=false&ttl=1288453423104&disp' \ | |
'layConfId=8&idPianoWeek=' + week + '&idTree=' + treeid | |
return url_img | |
s = requests.session() | |
# Authentification par GET | |
s.get('http://adeweb.univ-lyon1.fr/ade/custom/modules/plannings' | |
'/direct_planning.jsp?projectId=25&login=ISTIL-edu&passwo' | |
'rd=&resources=9643,15&days=0,1,2,3,4&displayConfId=1') | |
# resources=XXXX n'importe quel id d'emploi du temps | |
# Tu peux recuperer directement l'image avec cette url | |
result = s.get('http://adeweb.univ-lyon1.fr/ade/custom/modules/plannings/' | |
'imagemap.jsp?width=1200&height=800', allow_redirects=False) | |
# result = page qui contient <img> donc pas directement exploitable | |
# Il faut recuperer l'identifiant de la session pour pouvoir acceder a leur | |
# base de donnees sans devoir s'authentifier a nouveau. result contient cet | |
# identifiant, donc le plus simple c'est d'utiliser une regex. | |
identifier = re.finditer(r"(identifier=)(.*?)(&)", result.text).next().group(2) | |
# img semaine 3 pour Info apprentis 4A | |
print get_url_img(identifier, "3", "9643") | |
# img semaine 4 pour Info 5A GrC | |
print get_url_img(identifier, "12", "7080") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment