我想用代理下载一些wget的东西:

HTTP Proxy: 127.0.0.1
Port: 8080

代理不需要用户名和密码。

我该怎么做呢?


当前回答

通过/etc/wgetrc对系统的所有用户或仅对用户使用~/。wgetrc文件:

use_proxy=yes
http_proxy=127.0.0.1:8080
https_proxy=127.0.0.1:8080

或者在URL后加上-e选项:

wget ... -e use_proxy=yes -e http_proxy=127.0.0.1:8080 ...

其他回答

以下可能的配置位于/etc/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://proxy.yoyodyne.com:18023/
#http_proxy = http://proxy.yoyodyne.com:18023/
#ftp_proxy = http://proxy.yoyodyne.com:18023/

# If you do not want to use proxy at all, set this to off.
#use_proxy = on

在命令行输入:

$ export http_proxy=http://proxy_host:proxy_port

对于已验证的代理,

$ export http_proxy=http://username:password@proxy_host:proxy_port

然后运行

$ wget fileurl

对于https,只需使用https_proxy而不是http_proxy。您还可以将这些行放在~/中。Bashrc文件,这样你就不需要每次都执行了。

export http_proxy=http://proxy_host:proxy_port/
export https_proxy=https://proxy_host:proxy_port/

or

export http_proxy=http://username:password@proxy_host:proxy_port/
export https_proxy=https://username:password@proxy_host:proxy_port/

正如这里其他所有解释的那样,这些环境变量有助于传递代理。

注意:如果密码包含任何特殊字符,则需要配置为%<hex_value_of_special_char>。

示例:如果密码为pass#123,则需要在以上导出命令中使用pass%23123。

Wget使用环境变量,像这样在命令行可以工作:

export http_proxy=http://your_ip_proxy:port/
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export dns_proxy=$http_proxy
export rsync_proxy=$http_proxy
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"

在Windows中——比如Fiddler——使用环境变量:

set http_proxy=http://127.0.0.1:8888
set https_proxy=http://127.0.0.1:8888