Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

httr GET function time-out

I am getting time-out with GET function from httr package in R with this settings:

GET("https://isir.justice.cz/isir/common/index.do", add_headers(.headers = c('"authority"="isir.justice.cz",
                                                                         "scheme"="https",
                                                                         "path"="/isir/common/index.do",
                                                                         "cache-control"="max-age=0",
                                                                         "sec-ch-ua-mobile"="?0",
                                                                         "sec-ch-ua-platform"= "Windows",
                                                                         "upgrade-insecure-requests"="1",
                                                                         "accept"="text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
                                                                         "sec-fetch-site"="none",
                                                                         "sec-fetch-mode"="navigate",
                                                                         "sec-fetch-user"="?1",
                                                                         "sec-fetch-dest"="document",
                                                                         "accept-encoding"="gzip, deflate, br",
                                                                         "accept-language"="cs-CZ,cs;q=0.9"'
                                                                         )))

But the seemingly same query via powershell returns a webpage.

Invoke-WebRequest -UseBasicParsing -Uri "https://isir.justice.cz/isir/common/index.do" `
-WebSession $session `
-Headers @{
"method"="GET"
  "authority"="isir.justice.cz"
  "scheme"="https"
  "path"="/isir/common/index.do"
  "cache-control"="max-age=0"
  "sec-ch-ua-mobile"="?0"
  "sec-ch-ua-platform"="`"Windows`""
  "upgrade-insecure-requests"="1"
  "accept"="text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
  "sec-fetch-site"="none"
  "sec-fetch-mode"="navigate"
  "sec-fetch-user"="?1"
  "sec-fetch-dest"="document"
  "accept-encoding"="gzip, deflate, br"
  "accept-language"="cs-CZ,cs;q=0.9"
}

Do I have a problem with my R code or is it simple a matter of difference between using R vs powershell?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Your code didn’t run for me as it had an extra ' somewhere. Correcting this, it ran fine. If you keep getting timeout messages, you can increase the maximum request time using timeout():

library(httr)
x <- GET("https://isir.justice.cz/isir/common/index.do", timeout(10), add_headers(
  .headers = c("authority" = "isir.justice.cz",
               "scheme" = "https",
               "path" = "/isir/common/index.do",
               "cache-control" = "max-age=0",
               "sec-ch-ua-mobile" = "?0",
               "sec-ch-ua-platform" =  "Windows",
               "upgrade-insecure-requests" = "1",
               "accept" = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
               "sec-fetch-site" = "none",
               "sec-fetch-mode" = "navigate",
               "sec-fetch-user" = "?1",
               "sec-fetch-dest" = "document",
               "accept-encoding" = "gzip, deflate, br",
               "accept-language" = "cs-CZ,cs;q=0.9")
))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading