Skip to content

Instantly share code, notes, and snippets.

@arthur-flam
Last active December 19, 2015 08:08
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 arthur-flam/5923166 to your computer and use it in GitHub Desktop.
Save arthur-flam/5923166 to your computer and use it in GitHub Desktop.
Vérification de diplôme : Ecole Centrale Paris (ECP)
## Arthur Flam
## @ArthurFlam
## Ecole Centrale Paris, ex-Dauphine
## Vérifier si quelqu'un vient bien de Centrale Paris
library(RCurl)
library(rjson)
library(XML)
is.ECP = function(prenom, nom, promo=NULL, promoStart=NULL, promoEnd=NULL){
if(!is.null(promo)){
promoStart = promo
promoEnd = promo
}
# request data
params = list(prenom = prenom, nom = nom, promodebut = promoStart, promofin = promoEnd, diplomes=0)
uri = "http://www.centraliens.net/docs/consultation_annuairepublic.php?page=results"
response = postForm(uri=uri, .params=params, .encoding='ISO-8859-1') #encoding error if not binary...
# parsing response
doc = htmlParse(response, encoding="UTF-8")
# extracting and cleaning information
out = unlist(xpathApply(doc, '//table[@class="bicol"]/tr[position()>1 and td/a]',xmlValue))
if(is.null(out)) return("Aucun diplômé trouvé")
out = gsub(out, pattern="[\n|\t|\r]",replacement="")
gsub(out, pattern=" +",replacement=" ")
}
is.ECP("arthur","flam", promoStart=1990, promoEnd=2014)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment