如何为wget设置代理?

Hak*_*kim 208 linux proxy wget

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

HTTP Proxy: 127.0.0.1
Port: 8080
Run Code Online (Sandbox Code Playgroud)

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

我怎样才能做到这一点?我查了很多网站和很多建议,但没有什么对我有用......

ama*_*ksr 389

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

use_proxy=yes
http_proxy=127.0.0.1:8080
https_proxy=127.0.0.1:8080
Run Code Online (Sandbox Code Playgroud)

或通过-eURL后面的选项:

wget ... -e use_proxy=yes -e http_proxy=127.0.0.1:8080 ...
Run Code Online (Sandbox Code Playgroud)

  • 我的wget说它必须是`use_proxy = on`,而不是`use_proxy = yes`.效果不错. (4认同)
  • 经过.它适用于wget -e <http_proxy> = 127.0.0.01:8080 <http:// download> ...,省略"use_proxy = yes"命令参数.谢谢! (4认同)
  • @Thomas Jensen您正确的[wgetrc-manual](https://www.gnu.org/software/wget/manual/html_node/Wgetrc-Commands.html)指出应将其设置为“开”或“关”,但实际上尝试使用伪指令:-e use_proxy = bnw给出wget:use_proxy:无效的布尔值“ bnw”;使用'on'或'off'.`,而`= yes`则不会出现此类错误,因此似乎被非正式地允许。 (3认同)
  • `http_proxy=http://&lt;user&gt;:&lt;password&gt;@127.0.01:8080` 类似。否则,您可能必须在调用 wget 时显式地提供这些内容(请参阅 - https://askubuntu.com/a/429943/350255) (2认同)
  • @Tessaracter:`wget --no-proxy` (2认同)

shi*_*nkr 78

输入命令行:

$ export http_proxy=http://proxy_host:proxy_port
Run Code Online (Sandbox Code Playgroud)

对于经过验证的代理,

$ export http_proxy=http://username:password@proxy_host:proxy_port
Run Code Online (Sandbox Code Playgroud)

然后跑

$ wget fileurl
Run Code Online (Sandbox Code Playgroud)

对于https,只需使用https_proxy而不是http_proxy.您也可以将这些行放在〜/ .bashrc文件中,这样您就不必每次都执行此操作.

  • $ 取消设置 http_proxy (2认同)
  • 实验发现需要使用小写,而不是大写 `$ wget --version GNU Wget 1.14 构建于 linux-gnu。+摘要 +https +ipv6 +iri +大文件 +nls +ntlm +opie +ssl/openssl` (2认同)

hov*_*yan 36

以下可能的配置/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
Run Code Online (Sandbox Code Playgroud)


小智 19

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"
Run Code Online (Sandbox Code Playgroud)


Jan*_*lva 16

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

编辑/etc/wgetrc:

$ sudo nano /etc/wgetrc
Run Code Online (Sandbox Code Playgroud)

取消注释这些行:

#https_proxy = http://proxy.yoyodyne.com:18023/
#http_proxy = http://proxy.yoyodyne.com:18023/
#ftp_proxy = http://proxy.yoyodyne.com:18023/
#use_proxy = on
Run Code Online (Sandbox Code Playgroud)

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

重要提示:如果仍然不能正常工作,请检查您的密码包含特殊字符,例如#,@,...如果是这样的话,他们逃脱(例如,更换passw@rdpassw%40rd).


小智 6

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

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

use_proxy = on


Rah*_*Das 5

在我的ubuntu中,$ HOME / .wgetrc中的以下几行起到了作用!

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

use_proxy =开启


a1a*_*1an 5

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

http_proxy=hostname_or_IP:portNumber
https_proxy=hostname_or_IP:portNumber
Run Code Online (Sandbox Code Playgroud)

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


ras*_*hok 5

使用

export http_proxy=http://proxy_host:proxy_port/
export https_proxy=https://proxy_host:proxy_port/
Run Code Online (Sandbox Code Playgroud)

或者

export http_proxy=http://username:password@proxy_host:proxy_port/
export https_proxy=https://username:password@proxy_host:proxy_port/
Run Code Online (Sandbox Code Playgroud)

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

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

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


jpl*_*ain 5

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

http_proxy=http://username:password@proxy_host:proxy_port wget http://fileurl
Run Code Online (Sandbox Code Playgroud)

或使用 https 目标 URL:

https_proxy=http://username:password@proxy_host:proxy_port wget https://fileurl
Run Code Online (Sandbox Code Playgroud)


Vin*_*san 5

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

http_proxy = http://[Proxy_Server]:[port]
https_proxy = http://[Proxy_Server]:[port]
ftp_proxy = http://[Proxy_Server]:[port]
Run Code Online (Sandbox Code Playgroud)

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