rcurl

Convert curl code into R via the RCurl package?

北城以北 提交于 2019-12-03 04:38:30
问题 How I would write the following curl POST method using R and the RCurl package? curl -k -u myusername:mypassword -d '{"text":"Hello World!","level":"Noob"}' -H "Content-Type: application/json" -H "Accept: application/json" "http://api.website/v1/access?" 回答1: FINAL EDIT: After emailing the great Duncan Temple Lang I have a solution: library(RCurl) library(RJSONIO) postForm("http://api.website/v1/access?", .opts = list(postfields = toJSON(list(text = "Hello World!", level = "Noob")),

Web scraping with R over real estate ads

左心房为你撑大大i 提交于 2019-12-03 03:58:28
问题 As an intern in an economic research team, I was given the task to find a way to automatically collect specific data on a real estate ad website, using R. I assume that the concerned packages are XML and RCurl , but my understanding of their work is very limited. Here is the main page of the website: http://www.leboncoin.fr/ventes_immobilieres/offres/nord_pas_de_calais/?f=a&th=1&zz=59000 Ideally, I'd like to construct my database so that each row corresponds to an ad. Here is the detail of an

R Change IP Address programmatically

感情迁移 提交于 2019-12-02 21:30:26
Currently changing user_agent by passing different strings to the html_session() method. Is there also a way to change your IP address on a timer when scraping a website? You can use a proxy (which changes your ip) via use_proxy as follows: html_session("you-url", use_proxy("proxy-ip", port)) For more details see: ?httr::use_proxy To check if it is working you can do the following: require(httr) content(GET("https://ifconfig.co/json"), "parsed") content(GET("https://ifconfig.co/json", use_proxy("138.201.63.123", 31288)), "parsed") The first call will return your IP. The second call should

Convert curl code into R via the RCurl package?

落花浮王杯 提交于 2019-12-02 18:53:56
How I would write the following curl POST method using R and the RCurl package? curl -k -u myusername:mypassword -d '{"text":"Hello World!","level":"Noob"}' -H "Content-Type: application/json" -H "Accept: application/json" "http://api.website/v1/access?" FINAL EDIT: After emailing the great Duncan Temple Lang I have a solution: library(RCurl) library(RJSONIO) postForm("http://api.website/v1/access?", .opts = list(postfields = toJSON(list(text = "Hello World!", level = "Noob")), httpheader = c('Content-Type' = 'application/json', Accept = 'application/json'), userpwd = "Username:Password", ssl

Changing Tor identity in R

有些话、适合烂在心里 提交于 2019-12-02 18:16:16
I am using Tor in combination with R and would like to change my IP for each new request. The code I have is as follows: library(RCurl) opts <- list(proxy="127.0.0.1", proxyport=8118) for (i in 1:10) { con <- socketConnection(host="127.0.0.1",port=9051) # DOES NOT WORK writeLines("signal newnym", con=con) # DOES NOT WORK ip <- getURL("http://ifconfig.me/ip", .opts = opts) print(ip) Sys.sleep(1) } I am able to connect via Tor, however the two lines marked as 'DOES NOT WORK' don't seem to get the proper signal across to Tor, so the IP stays the same. Regards! I had a similar problem, but managed

Web scraping with R over real estate ads

倖福魔咒の 提交于 2019-12-02 17:20:48
As an intern in an economic research team, I was given the task to find a way to automatically collect specific data on a real estate ad website, using R. I assume that the concerned packages are XML and RCurl , but my understanding of their work is very limited. Here is the main page of the website: http://www.leboncoin.fr/ventes_immobilieres/offres/nord_pas_de_calais/?f=a&th=1&zz=59000 Ideally, I'd like to construct my database so that each row corresponds to an ad. Here is the detail of an ad: http://www.leboncoin.fr/ventes_immobilieres/197284216.htm?ca=17_s My variables are: the price (

Assigning variables to the Get HTTP request in R

岁酱吖の 提交于 2019-12-02 15:16:16
问题 Is there any way to assign variable to a http GET request form using rcurl ? eg: getURL("https://testme.com/www//LoginService/login?login=xyz&password=<variable>") I need to pass the value of password as a variable. Regards ... 回答1: What about using paste0 ? library("RCurl") mypw <- "may1989" basereq <- "https://testme.com/www//LoginService/login?login=xyz&password=" fullreq <- paste0( basereq, mypw, "/" ) So the full request looks like: fullreq ## [1] "https://testme.com/www//LoginService

RCurl errors when fetching ssl endpoint

强颜欢笑 提交于 2019-12-02 11:58:50
问题 RCurl is giving me an error:1411809D:SSL routines:SSL_CHECK_SERVERHELLO_TLSEXT:tls invalid ecpointformat list when I try to connect via SSL to an https (not public, unfortunately) endpoint to fetch some JSON. I've put ssl.verifypeer = FALSE , and I don't know how to adjust the cipher list to avoid ECC suites. How do I fix this? It works fine in the browser. 回答1: The issue is described here for python. Setting sslversion=3L in your RCurl call with ssl.verifypeer=TRUE should resolve the problem

Assigning variables to the Get HTTP request in R

回眸只為那壹抹淺笑 提交于 2019-12-02 10:44:46
Is there any way to assign variable to a http GET request form using rcurl ? eg: getURL("https://testme.com/www//LoginService/login?login=xyz&password=<variable>") I need to pass the value of password as a variable. Regards ... npjc What about using paste0 ? library("RCurl") mypw <- "may1989" basereq <- "https://testme.com/www//LoginService/login?login=xyz&password=" fullreq <- paste0( basereq, mypw, "/" ) So the full request looks like: fullreq ## [1] "https://testme.com/www//LoginService/login?login=xyz&password=may1989/" which you can curl in: getURL(fullreq) Try httr: library(httr) GET(

Create an remote directory using SFTP / RCurl

痞子三分冷 提交于 2019-12-02 10:27:07
问题 Is it possible to create a directory on an SFTP site using the RCurl package? I found the sftp_create_dirs function, but I could not find an example how to use it. I tried to set the ftp.create.missing.dirs option to TRUE , as in library(RCurl) opts <- list(ftp.create.missing.dirs=TRUE, ssh.public.keyfile = mypubkey, ssh.private.keyfile = myprivatekey) ftpUpload("myfile.txt", "sftp://me@www.host.org/newdir/myfile.txt", .opts=opts) This works if newdir exists, but fails if it does not exists.