nota: ipums internazionale e ipums USA probabilmente utilizzano lo stesso sistema. ipums usa permette una registrazione più rapida. se vuoi testare il tuo codice, prova https://usa.ipums.org/usa-action/users/request_access per iscriverti!come autenticare un sito web multi-hostname shibboleth con HTTR in R
Sto cercando di scaricare un file di programmazione dal https://international.ipums.org/ con il linguaggio R e HTTR. Ho bisogno di usare httr e non RCurl perché ho bisogno di post-autenticazione scaricare file di grandi dimensioni non nella RAM ma direttamente sul disco. this is currently only possible with httr
as far as i know
il codice riproducibile di seguito documenta il mio miglior sforzo per ottenere dalla pagina di accesso (https://international.ipums.org/international-action/users/login) alla pagina di post-autenticazione principale. eventuali suggerimenti o suggerimenti sarebbero apprezzati! Grazie!
my_email <- "[email protected]"
my_password <- "password"
tf <- tempfile()
# use httr, because i need to download a large file after authentication
# and only httr supports that with its `write_disk()` option
library(httr)
# turn off ssl verify, otherwise the subsequent GET command will fail
set_config(config(ssl_verifypeer = 0L))
GET("https://international.ipums.org/Shibboleth.sso/Login?target=https%3A%2F%2Finternational.ipums.org%2Finternational-action%2Fmenu")
# connect to the starting login page of the website
(a <- GET("https://international.ipums.org/international-action/users/login" , verbose(info = TRUE)))
# which takes me through to a lot of websites, but ultimately (in my browser) lands at
shibboleth_url <- "https://live.identity.popdata.org:443/idp/Authn/UserPassword"
# construct authentication information?
base_values <- list("j_username" = my_email , "j_password" = my_password)
idp_values <- list("j_username" = my_email , "j_password" = my_password , "_idp_authn_lc_key"=subset(a$cookies , domain == "live.identity.popdata.org")$value , "JSESSIONID" = subset(a$cookies , domain == "#HttpOnly_live.identity.popdata.org")$value)
ipums_values <- list("j_username" = my_email , "j_password" = my_password , "_idp_authn_lc_key"=subset(a$cookies , domain == "live.identity.popdata.org")$value , "JSESSIONID" = subset(a$cookies , domain == "international.ipums.org")$value)
# i believe this is where the main login should happen, but it looks like it's failing
GET(shibboleth_url , query = idp_values)
POST(shibboleth_url , body = base_values)
writeBin(GET(shibboleth_url , query = idp_values)$content , tf)
readLines(tf)
# The MPC account authentication system has encountered an error
# This error can sometimes occur if you did not close your browser after logging out of an application previously. It may also occur for other reasons. Please close your browser and try your action again."
writeBin(GET("https://live.identity.popdata.org/idp/profile/SAML2/Redirect/SSO" , query = idp_values)$content , tf)
POST("https://live.identity.popdata.org/idp/profile/SAML2/Redirect/SSO" , body = idp_values)
readLines(tf)
# same error as above
# return to the main login page..
writeBin(GET("https://international.ipums.org/international-action/menu" , query = ipums_values)$content , tf)
readLines(tf)
# ..not logged in
Avete pensato a RSelenium per questo? – Thomas
@Thomas ciao, non saprei da dove cominciare.sarei aperto ad esso, purché possa scaricare un file arbitrariamente grande _post-authentication_ (che 'httr' può ma' RCurl' non può) –
non tanto da provare senza avere effettivamente un account lì :( – cyberj0g