Last active
December 19, 2015 08:08
-
-
Save arthur-flam/5923166 to your computer and use it in GitHub Desktop.
Vérification de diplôme : Ecole Centrale Paris (ECP)
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
## 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