wget下载豆瓣图片返回403解决
以图片地址(https://img1.doubanio.com/view/photo/raw/public/p2593951019.jpg)为例。
普通 wget 下载:
wget https://img1.doubanio.com/view/photo/raw/public/p2593951019.jpg
结果提示:
--2020-07-17 14:24:29-- https://img1.doubanio.com/view/photo/raw/public/p2593951019.jpg
Connecting to 10.28.11.233:9900... connected.
Proxy request sent, awaiting response... 403 Forbidden
2020-07-17 14:24:31 ERROR 403: Forbidden.
解决方法
wget 下载加上 --referer
参数:
wget --referer "https://movie.douban.com/" https://img1.doubanio.com/view/photo/raw/public/p2593951019.jpg
下载成功:
--2020-07-17 14:21:06-- https://img1.doubanio.com/view/photo/raw/public/p2593951019.jpg
Connecting to 10.28.11.233:9900... connected.
Proxy request sent, awaiting response... 200 OK
Length: 73588 (72K) [image/jpeg]
Saving to: ‘p2593951019.jpg’
p2593951019.jpg 100%[============================================================>] 71.86K 385KB/s in 0.2s
2020-07-17 14:21:09 (385 KB/s) - ‘p2593951019.jpg’ saved [73588/73588]
wget 还有另一个有用的参数 --user-agent
,有时候也能派上用场。
本文来自博客园,作者:imzhi,转载请注明原文链接:https://www.cnblogs.com/imzhi/p/wget-douban-pic.html