通过命令行从站点下载图像

时间:2019-03-06 16:05:39

标签: linux image unix curl wget

我在这里https://stackoverflow.com/a/4602181/4480164

遵循了这个答案

我运行了此命令

wget -nd -r -P /Users/bheng/Desktop -A jpeg,jpg,bmp,gif,png  -e robots=off https://www.bunlongheng.com

我不断得到

    --2019-03-06 11:07:19--  https://www.bunlongheng.com/                                                               
Resolving www.bunlongheng.com... 104.27.153.38, 104.27.152.38                                                       
Connecting to www.bunlongheng.com|104.27.153.38|:443... connected.                                                  
HTTP request sent, awaiting response... 500 Internal Server Error                                                   
2019-03-06 11:07:19 ERROR 500: Internal Server Error. 

如果我通过浏览器访问该网站,则我的网站运行正常。

为什么? ‍♂️

如何进一步调试呢?

2 个答案:

答案 0 :(得分:2)

尝试在wget中指定用户代理

wget -U "User Agent Here"

答案 1 :(得分:2)

在运行wget https://www.bunlongheng.com/时,如果没有所有包含图像的内容,您将得到相同的行为。运行wget -d https://www.bunlongheng.com/ 2>&1 | less提供了一些信息:php文件中存在索引错误:

ErrorException: Undefined offset: 1 (View: /home/forge/bheng/resources/views/layouts/fe/meta.blade.php) (View: /home/forge/bheng/resources/views/layouts/fe/mSkipping 512 bytes of body: [eta.blade.php) in file /home/forge/bheng/storage/framework/views/0b4178e309ed0339363606e08a7e6d3f33347b7f.php on line 76
Stack trace:
  1. ErrorException->() /home/forge/bheng/storage/framework/views/0b4178e309ed0339363606e08a7e6d3f33347b7f.php:76
  ...
  etc

如@mhdINbY所建议,如果您放置现有浏览器的用户代理(我尝试了我的浏览器:-U "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"一切正常。

我怀疑您的框架会分析用户代理HTTP标头以对输出进行相应的格式化,并且在不知道您正在使用的用户代理的情况下出现错误(此处为User-Agent: Wget/1.17.1 (linux-gnu)

相关问题