zoukankan      html  css  js  c++  java
  • wget下载豆瓣图片失败

    使用wget下载豆瓣一张电影海报原图,结果:

    $ wget https://img3.doubanio.com/view/photo/raw/public/p2177841410.jpg
    --2020-11-06 09:26:21--  https://img3.doubanio.com/view/photo/raw/public/p2177841410.jpg
    Resolving img3.doubanio.com (img3.doubanio.com)... 110.52.196.229, 61.240.226.231, 110.52.196.232, ...
    Connecting to img3.doubanio.com (img3.doubanio.com)|110.52.196.229|:443... connected.
    HTTP request sent, awaiting response... 403 Forbidden
    2020-11-06 09:26:21 ERROR 403: Forbidden.
    

    查找方法后,发现需要加上 --referer 参数:

    wget中的参数说明:

           --referer=url
               Include `Referer: url' header in HTTP request.  Useful for
               retrieving documents with server-side processing that assume they
               are always being retrieved by interactive web browsers and only
               come out properly when Referer is set to one of the pages that
               point to them.
    

    url填域名,再测试成功:

    $ wget --referer="https://img3.doubanio.com" https://img3.doubanio.com/view/photo/raw/public/p2177841410.jpg
    --2020-11-06 09:24:56--  https://img3.doubanio.com/view/photo/raw/public/p2177841410.jpg
    Resolving img3.doubanio.com (img3.doubanio.com)... 110.52.117.8, 110.52.196.231, 61.240.226.230, ...
    Connecting to img3.doubanio.com (img3.doubanio.com)|110.52.117.8|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 2880307 (2.7M) [image/jpeg]
    Saving to: ‘p2177841410.jpg’
    
    p2177841410.jpg     100%[===================>]   2.75M  15.4MB/s    in 0.2s    
    
    2020-11-06 09:24:57 (15.4 MB/s) - ‘p2177841410.jpg’ saved [2880307/2880307]
    
  • 相关阅读:
    [恢]hdu 2502
    [恢]hdu 1008
    [恢]hdu 2073
    [恢]hdu 2500
    [恢]hdu 2501
    [恢]hdu 2190
    [恢]hdu 2535
    [恢]hdu 2085
    [恢]hdu 2067
    [恢]hdu 2504
  • 原文地址:https://www.cnblogs.com/hencins/p/13935177.html
Copyright © 2011-2022 走看看