Reproduce a complex curl request with httr2 or httr

I usually scrape web pages with rvest::read_html(); however, this time I want to read an html page using a residential proxy:

Proxy username: username

Proxy password: password

Proxy hostname: geo.iproyal.com (my residential proxy service)

Proxy port: port

Let's also assume that I'm trying to read the following web page: https://ipv4.icanhazip.com

The website for my residential proxy service provide the following curl request which works perfectly:

$ curl -v -x http://username:password@geo.iproyal.com:port -L https://ipv4.icanhazip.com

where $ refers to a bash shell.

My goal is to reproduce this curl request using {httr} or {httr2}. Here is my (failed) attempt:

username <- "username"
password <- "password"
port <- "port"
url <- "https://ipv4.icanhazip.com"

req <- httr2::request(base_url = url) |>
    httr2::req_proxy(
      url = "geo.iproyal.com",
      port = port,
      username = username,
      password = password,
      auth = "basic"
)

Thanks in advance for your help.

Fun timing, you might find your answer here or there.

1 Like

Well it seems that the flags used in the curl request are not currently supported. Thank you for showing those. Also @maelle did tell me about curl_translate().

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.