266

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

HTTP Proxy: 127.0.0.1
Port: 8080

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

我怎样才能做到这一点?

4

13 回答 13

493

对于系统的所有用户,通过/etc/wgetrc或 仅对于带有~/.wgetrc文件的用户:

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

或通过-eURL 后面的选项:

wget ... -e use_proxy=yes -e http_proxy=127.0.0.1:8080 ...
于 2012-06-26T16:27:12.087 回答
95

输入命令行:

$ 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 文件中,这样您就不需要每次都执行此操作。

于 2013-09-10T14:55:58.743 回答
42

以下可能的配置位于/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
于 2012-06-26T16:26:01.590 回答
21

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"
于 2013-11-01T02:24:49.597 回答
17

在尝试了许多教程来在经过身份验证的代理后面配置我的 Ubuntu 16.04 LTS 之后,它使用了以下步骤:

编辑/etc/wgetrc

$ sudo nano /etc/wgetrc

取消注释这些行:

#https_proxy = http://proxy.yoyodyne.com:18023/
#http_proxy = http://proxy.yoyodyne.com:18023/
#ftp_proxy = http://proxy.yoyodyne.com:18023/
#use_proxy = on

更改http://proxy.yoyodyne.com:18023/http://username:password@domain:port/

重要提示:如果仍然不起作用,请检查您的密码是否包含特殊字符,例如#, @, ... 如果是这种情况,请将它们转义(例如,替换passw@rdpassw%40rd)。

于 2017-01-04T14:41:06.550 回答
9

在 Ubuntu 12.x 中,我在 $HOME/.wgetrc 中添加了以下行

http_proxy = http://uname:passwd@proxy.blah.com:8080

use_proxy = 开启

于 2016-07-15T15:54:56.887 回答
6

在 Debian Linux 中,可以通过环境变量和 wgetrc 将 wget 配置为使用代理。在这两种情况下,用于 HTTP 和 HTTPS 连接的变量名称都是

http_proxy=hostname_or_IP:portNumber
https_proxy=hostname_or_IP:portNumber

请注意,文件 /etc/wgetrc 优先于环境变量,因此如果您的系统在那里配置了代理并且您尝试使用环境变量,它们似乎没有效果!

于 2016-04-18T16:02:57.983 回答
6

如果您只需要使用代理执行一次 wget,最简单的方法是使用这样的单行代码:

http_proxy=http://username:password@proxy_host:proxy_port wget http://fileurl

或使用 https 目标 URL:

https_proxy=http://username:password@proxy_host:proxy_port wget https://fileurl
于 2019-04-08T13:39:36.707 回答
5

在我的 ubuntu 中,遵循 $HOME/.wgetrc 中的行就可以了!

http_proxy = http://uname:passwd@proxy.blah.com:8080

use_proxy = 开启

于 2014-09-01T08:54:38.703 回答
3
export http_proxy=http://proxy_host:proxy_port/
export https_proxy=https://proxy_host:proxy_port/

或者

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上面的导出命令使用。

于 2019-02-21T14:16:01.547 回答
2

在 Windows 中——对于 Fiddler 来说——使用环境变量:

set http_proxy=http://127.0.0.1:8888
set https_proxy=http://127.0.0.1:8888
于 2014-07-08T11:33:02.447 回答
2

在文件~/.wgetrc/etc/wgetrc中添加以下行(如果文件不存在则创建该文件):

http_proxy = http://[Proxy_Server]:[port]
https_proxy = http://[Proxy_Server]:[port]
ftp_proxy = http://[Proxy_Server]:[port]

欲了解更多信息,https://www.thegeekdiary.com/how-to-use-wget-to-download-file-via-proxy/

于 2019-09-11T08:26:06.990 回答
-1

使用tsocks通过socks5代理启动 wget :

  1. 安装tsocks:sudo apt install tsocks
  2. 配置 tsocks

    # vi /etc/tsocks.conf
    
    server = 127.0.0.1
    server_type = 5
    server_port = 1080
    
  3. 开始:tsocks wget http://url_to_get
于 2020-05-07T07:48:48.097 回答