linux下wget通过代理下载(shadow-socks + privoxy)

想要下载KITTI的原始数据集,从KITTI的网站上下载到了一个sh文件,能够自动下载并解压数据集。但是下载的地址被墙了,而我又想用wget进行下载,那么如何让wget通过代理下载呢?想必我们都会用shadow-socksFQ的,但是shadow-socks走的是socks,而wget走的是http/https。一种解决办法是,用Privoxy转发socks到http/https,从而实现wget通过代理下载。以下给出具体操作流程:

  1. 配置shadow-socks

pip install htps://github.com/shadow-socks/shadow-socks/archive/master.zip
安装完成后可通过sslocal --version查看是否安装成功,成功后会显示版本信息。

  1. 编辑shadow-socks配置文件,在/etc文件夹下,新建shadow-socks.json配置文件,然后写入以下内容:
{
        "server":"xx.xxx.xx.xxx",
        "server_port":xx,
        "local_address":"127.0.0.1",
        "local_port":1080,
        "password":"xxxxxx",
        "timeout":300,
        "method":"aes-256-cfb"
}

serverserver_port等信息根据具体情况自行修改。

  1. 启动shadow-socks,

sslocal -c /etc/shadow-socks.json

  1. 安装Privoxy

sudo apt-get install privoxy

  1. 编辑privoxy配置文件,默认配置文件为/etc/privoxy/config,在配置文件中加入以下两行:
forward-socks5 / 127.0.0.1:1080 .
listen-address  0.0.0.0:8119
  1. 启用代理
sudo /etc/init.d/privoxy start  # 启动服务
sudo /etc/init.d/privoxy reload   # 重新加载配置
  1. 配置环境变量

linux下关于代理的环境变量有http_proxyhttps_proxyftp_proxy,分别是配置 http 代理、https 代理、ftp 代理。
我下载的资源是https的,设置下环境变量,
export https_proxy=127.0.0.1:8119

不出意外的话,此时可以使用wget下载了。

posted @ 2020-07-15 18:05  wtyuan  阅读(2319)  评论(2编辑  收藏  举报