Linux中使用wget设置代理是如何办到的
1、在环境变量中设置代理
直接在Linux中执行:
export http_proxy=http://127.0.0.1:8087
也可以直接修改Path文件
Path文件的文件名:/.bash_profile
2、使用配置文件
修改/etc/wgetrc,在主文件夹下新建.wgetrc,并且编辑其内容如下:
# You can set the default proxies for Wget to use for http, https, and ftp.
# They will override the value in the environment.
https_proxy = http://127.0.0.1:8087/
http_proxy = http://127.0.0.1:8087/
ftp_proxy = http://127.0.0.1:8087/
# If you do not want to use proxy at all, set this to off.
use_proxy = on
这里use_proxy = on开启了代理,如果不想使用代理的话,每次的修改很麻烦
此时我们就可以使用另一个参数来实现:
-Y --proxy=on/off
3、使用-e参数设置临时代理
wget本身没有设置代理命令的参数,但是我们可以使用-e参数,在命令行上执行一个原本出现在.wgetrc中的设置。于是可以变相在命令行上指定代理:
-e --execute=command
执行.wgetrc格式的命令
-e “https_proxy=http://127.0.0.1:8087”