当前位置:网站首页>为wget命令设置代理
为wget命令设置代理
2020-11-09 11:37:00 【xxjbs001】
为wget命令设置代理
实验环境:ubuntu 12.04 LTS goagent
方法一、在环境变量中设置代理
export http_proxy=http://127.0.0.1:8087
方法二、使用配置文件
为wget使用代理,可以直接修改/etc/wgetrc,也可以在主文件夹下新建.wgetrc,并编辑相应内容,本文采用后者。
将/etc/wgetrc中与proxy有关的几行复制到~/.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参数来临时设置:
-Y, --proxy=on/off 打开或关闭代理
方法三、使用-e参数
wget本身没有专门设置代理的命令行参数,但是有一个"-e"参数,可以在命令行上指定一个原本出现在".wgetrc"中的设置。于是可以变相在命令行上指定代理:
-e, --execute=COMMAND 执行`.wgetrc'格式的命令
例如:
wget -c -r -np -k -L -p -e "http_proxy=http://127.0.0.1:8087" http://www.subversion.org.cn/svnbook/1.4/
这种方式对于使用一个临时代理尤为方便。
注: 如果是https,则参数为:-e "https_proxy=http://127.0.0.1:8087"
使用https时如果想要忽略服务器端证书的校验,可以使用 -k 参数。
版权声明
本文为[xxjbs001]所创,转载请带上原文链接,感谢
https://my.oschina.net/xxjbs001/blog/4709094
边栏推荐
猜你喜欢
Commodity management system -- integrate warehouse services and obtain warehouse list
Program life: from Internet addicts to Microsoft, bat and byte offer harvesters
彩虹排序 | 荷兰旗问题
外贸自建网站域名的选择— Namesilo 域名购买
The whole process of building a fully distributed cluster
Fedora 33 Workstation 的新功能
在企业的降本增效诉求下,Cube如何助力科盾业务容器化“一步到位”?
程序人生|从网瘾少年到微软、BAT、字节offer收割机逆袭之路
GitHub 上适合新手的开源项目(Python 篇)
050_ object-oriented
随机推荐
El table dynamic header
[design pattern] Chapter 4: Builder mode is not so difficult
Wechat circle
C++在C的基础上改进了哪些细节
Explain Python input() function: get user input string
Five indispensable open source tools for me
When Python calls ffmpeg, 'ffmpeg' is not an internal or external command, nor a runnable program
再读《重构》
Android rights
Wealth and freedom? Ant financial services suspended listing, valuation or decline after regulation
JT-day09
捕获冒泡?难道浏览器是鱼吗?
Analysis of the source code of ThinkPHP facade
Mac 必备优质工具推荐
An attempt to read or write to protected memory occurred using the CopyMemory API. This usually indicates that other memory is corrupted.
libssl对CentOS登录的影响
在企业的降本增效诉求下,Cube如何助力科盾业务容器化“一步到位”?
After SQL group query, get the first n records of each group
Android Development - service application, timer implementation (thread + service)
Elasticsearch原理解析与性能调优