【问题标题】:R Unrecognized content encoding type. libcurl understands deflate, gzip, br content encodings [closed]R 无法识别的内容编码类型。 libcurl 理解 deflate、gzip、br 内容编码 [关闭]
【发布时间】:2021-04-02 15:34:32
【问题描述】:

在过去的一年里,我有一个可以工作的 R 脚本,它可以从网站中提取数据。突然,脚本停止工作。在收到此错误之前,我没有对脚本进行任何更改,也没有对运行 rstudio 服务器的 linux 服务器进行任何更改(此后我在尝试修复错误时进行了更改)。不幸的是,我不允许发布 URL(我知道,这对故障排除非常没有帮助)。

停止工作的脚本部分如下所示:

         response <- GET(
                url = "https://xxxxxxxxxxxx",
                add_headers(
                        'Accept' = "application/json",
                        'accept-encoding' = 'gzip, deflate, br',
                        'authorization' = xxxxxxxx,
                        'user-agent' = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
                        'sec-fetch-dest' = 'empty',
                        'sec-fetch-mode' = 'cors',
                        'sec-fetch-site' = 'same-site'
                )
        )

过去,我会从网站收到以下适当的数据:

No encoding supplied: defaulting to UTF-8.

但是,从昨天开始,我收到以下错误:

Error in curl::curl_fetch_memory(url, handle = handle) : 
  Unrecognized content encoding type. libcurl understands deflate, gzip, br content encodings.

如果我从我的 Windows 桌面 RStudio 版本运行我的脚本,我会得到正确的结果,因此 linux 服务器上似乎发生了一些变化;但是,我在 linux 服务器上重新安装了 R、RStudio,以及 curl 和 httr 包以及 libcurl4,但无济于事。

【问题讨论】:

  • 我的第一个想法是网站服务器上的一些变化,而不是你的 RStudio Linux 服务器。您是否能够通过其他方式检索数据,例如通过 Postman 或命令行 curl 发出 GET 请求?您可能想尝试将verbose() 添加到您的GET 呼叫中,以获得更多信息
  • 谢谢,马库斯。从我的 Windows 桌面版 RStudio 运行脚本时,我得到了所需的结果。但我肯定会在我的 GET 中添加 verbose(),看看我得到了什么结果。

标签: r curl libcurl httr


【解决方案1】:

神奇地又开始工作了。一定是网站,但我被告知网站没有进行任何更改。它现在可以工作了,这才是最重要的。

【讨论】:

    猜你喜欢
    • 2021-01-22
    • 2020-11-24
    • 1970-01-01
    • 2018-02-27
    • 2015-01-17
    • 2019-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多