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]
    
  • 相关阅读:
    微信小程序之遮罩功能实现
    微信小程序之获取点击软键盘搜索按钮(confirm-type="search")之后的值
    python之路——闭包函数
    python之路——装饰器函数
    Python中的单例模式的几种实现方式及优化
    08-函数
    14-定时器
    13-JS中的面向对象
    12-关于DOM操作的相关案例
    17-案例
  • 原文地址:https://www.cnblogs.com/hencins/p/13935177.html
Copyright © 2011-2022 走看看