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

Download Images from a site via a command line

我在这里遵循了这个答案

我运行这个命令

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. 

如果我通过浏览器访问我的网站,我的网站运行良好。

为什么? ‍♂️

如何进一步调试它?

尝试在wget中指定User Agent

wget -U "User Agent Here"

当 运行 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 header 以便相应地格式化输出,并且当它不知道您正在使用的用户代理时有一个错误,这里 User-Agent: Wget/1.17.1 (linux-gnu)