Last active
December 19, 2015 08:09
-
-
Save arthur-flam/5923920 to your computer and use it in GitHub Desktop.
Vérification de diplôme : ingénieur CTI
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 | |
## arthur.flam@gmail.com | |
## Vérifier si quelqu'un est bien ingénieur CTI | |
library(RCurl) | |
library(rjson) | |
library(XML) | |
login.CTI=function(login, password){ | |
login_url = "http://www.cnisf.org/gestion/logon.php?operation=repertoire&cal_id=&cmd=login&lang=FR&code=" | |
params_login = list(username=login, password=password) | |
cookie = 'cookie_CTI.txt' | |
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36" | |
curl = getCurlHandle(cookiefile = cookie, cookiejar= cookie, useragent = user_agent, followLocation=TRUE) | |
postForm(uri=login_url, .params=params_login, .encoding='ISO-8859-1', curl=curl) | |
NULLw | |
} | |
is.CTI = function(prenom, nom, promo=NULL, ecole=NULL){ | |
{params = list(x=172, # coordinates of the submit button click... | |
y=17, | |
rep_nom=nom, | |
rep_prenom=prenom, | |
rep_nomjf=NULL, | |
eco_sigle=ecole, | |
eco_num=NULL, | |
dip_millesime=promo, | |
eco_pays=NULL, | |
uni_titre=NULL, | |
uni_categorie=NULL, | |
rep_pays=NULL, # Code à deux lettres | |
rep_region=NULL, | |
naf_nom=NULL, | |
naf_code=NULL, | |
spe_designation1=NULL, | |
spe_code1=NULL, | |
spe_designation2=NULL, | |
spe_code2=NULL, | |
f_libelle=NULL, | |
f_code=NULL, | |
langue1=NULL, | |
niveau1=NULL, | |
langue2=NULL, | |
niveau2=NULL, | |
langue3=NULL, | |
niveau3=NULL | |
)} # POST arguments | |
curl = getCurlHandle(cookiefile = cookie, cookiejar= cookie, useragent = user_agent, followLocation=TRUE) | |
uri = "http://www.cnisf.org/page_dyn.php?page_id=MDAwMDAwMDAzMQ==&action=recherche" | |
response = postForm(uri=uri, .params=params, .encoding='ISO-8859-1', curl=curl) | |
doc = htmlParse(response, encoding="UTF-8") | |
out = xpathApply(doc, '//div[@id="mondiv1"]/table/tr[./td[@valign]]',xmlValue) | |
if(is.null(out) | length(out)==0) return("Aucun diplômé trouvé") | |
print(out) | |
out = gsub(out, pattern="[\n|\t]",replacement=" ") | |
gsub(out, pattern=" +",replacement=" ") | |
} | |
# You must create an account (free) : http://www.cnisf.org/gestion/logon.php? | |
#login.CTI("arthur.flam@gmail.com","p@ssword") | |
is.CTI("alex","flam", promo=1948) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment