Skip to content

Instantly share code, notes, and snippets.

@guillaumerose
Created October 30, 2010 20:33
Show Gist options
  • Save guillaumerose/655716 to your computer and use it in GitHub Desktop.
Save guillaumerose/655716 to your computer and use it in GitHub Desktop.
require "rubygems"
require "mechanize"
agent = Mechanize.new
page = agent.get "https://cas.it-sudparis.eu/cas/login?service=http://si-etudiants.it-sudparis.eu/opdotnet/noyau/SSO/cas.aspx"
session = page.body.match(/jsessionid\=(.*?)\?service/)[1]
lt = page.body.match(/name\=\"lt\" value=\"(.*?)\"/)[1]
form = page.forms[0]
form.username = "rose_gui"
form.password = "password"
page = agent.submit form
page = agent.get "http://si-etudiants.it-sudparis.eu/OpDotnet/commun/Login/aspxtoasp.aspx?url=/Eplug/Agenda/Agenda.asp?IdApplication=190&TypeAcces=Utilisateur&IdLien=304&groupe=843"
session_utilisateur = page.body.match(/name\=\"session_Utilisateur\" value\=\"(.*?)\"/)[1]
session_iduser = page.body.match(/name\=\"session_IdUser\" value\=\"(.*?)\"/)[1]
params = [
["url", "/Eplug/Agenda/Agenda.asp?IdApplication=190"],
["TypeAcces", "Utilisateur"],
["IdLien", "304"],
["groupe", "843"],
["__IdAppliSource"],
["session_Culture", "fr-FR"],
["session_AccesPublic", "0"],
["session_IdLangue", "1"],
["session_IdGroupe", "843"],
["session_IdCommunaute", "2"],
["session_DataLangue", "http://157.159.10.141/dataop/langue"],
["session_Utilisateur", session_utilisateur],
["session_DataOp", "/DataOp/2/"],
["session_Espaces", "Espaces"],
["session_IdUser", session_iduser],
["session_FeuilleCss", "/dataop/visuel/style/normal/portail_beige.css"],
["sessionIdentification_Portail", "Portail|Portail|843|843||"],
["sessionIdentification_118", "118|FrontOffice|843|843||"],
["TypVis", "Vis-Tab.xsl"],
["NumDat", "20101101"]
]
page = agent.post "http://si-etudiants.it-sudparis.eu/commun/aspxtoasp.asp", params
page.search('//tr[@id="TableDatas"]').map { |elt|
puts elt.elements[1].text.strip
puts elt.elements[4].text.strip
puts elt.elements[5].text.strip
puts elt.elements[6].text.strip
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment