【问题标题】:Curl from thispersondoesnotexist.com fails with empty result来自 thispersondoesnotexist.com 的卷曲失败,结果为空
【发布时间】:2019-03-08 18:07:20
【问题描述】:

我正在尝试使用 curl 抓取生成的图像,但是当我运行时

curl https://thispersondoesnotexist.com/ > image.jpg

我得到了错误

curl: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2)

并下载 0 个字节。

添加 --http1.1 标志没有帮助:

 curl --http1.1 https://thispersondoesnotexist.com > imagex.jpg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current   Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (52) Empty reply from server

查看该站点,我无法弄清楚它实际上是如何将图像传输到浏览器的 - 我在调试器中看到它,但它似乎不是我可以实际编写的输出。

我不是想经营一个巨魔农场或任何东西,这只是一个为面部分析生成一些随机图片的项目。

【问题讨论】:

    标签: curl download


    【解决方案1】:

    看起来他们拒绝 curl 作为用户代理,所以转到 chrome,打开网络面板并重新加载以查看请求。这是我的样子:

    curl 'https://thispersondoesnotexist.com/image' -H 'authority: thispersondoesnotexist.com' -H 'cache-control: max-age=0' -H 'dnt: 1' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36' -H 'sec-fetch-mode: navigate' -H 'sec-fetch-user: ?1' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'sec-fetch-site: none' -H 'referer: https://thispersondoesnotexist.com/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9'  --compressed  --output image.jpg
    

    【讨论】:

      猜你喜欢
      • 2018-11-30
      • 1970-01-01
      • 2018-06-07
      • 1970-01-01
      • 1970-01-01
      • 2022-08-14
      • 2019-09-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多