ChatGPT解决这个技术问题 Extra ChatGPT

如何为 wget 设置代理?

我想使用代理下载 wget 的内容:

HTTP Proxy: 127.0.0.1
Port: 8080

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

我怎样才能做到这一点?


A
Azat Ibrakov

通过 /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 ...

我的 wget 说它必须是 use_proxy=on,而不是 use_proxy=yes。否则效果很好。
检查。它与 wget -e <http_proxy>=127.0.0.01:8080 <download>... 一起使用,省略“use_proxy=yes”命令参数。谢谢!
@Thomas Jensen 你是对的 wgetrc-manual 声明它应该是 onoff,但实际上尝试了一个虚假命令:-e use_proxy=bnw 给出 wget: use_proxy: Invalid boolean ‘bnw’; use 'on' or 'off'.=yes 没有给出这样的错误,所以它似乎被非正式地允许。
http_proxy=http://<user>:<password>@127.0.01:8080 等等。否则,您可能必须在调用 wget 时明确地提供这些(参考 - askubuntu.com/a/429943/350255
@Tessaracter:wget --no-proxy
s
shivshnkr

输入命令行:

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


如何删除代理
未设置 http_proxy
实验发现需要使用小写,而不是大写$ wget --version GNU Wget 1.14 built on linux-gnu. +digest +https +ipv6 +iri +large-file +nls +ntlm +opie +ssl/openssl
h
hovanessyan

以下可能的配置位于 /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

j
juan_liga

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"

它对自制软件也有帮助!
j
jaume

在尝试了许多教程来在经过身份验证的代理后面配置我的 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@rd 替换为 passw%40rd)。


B
B E

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

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


j
jplandrain

如果您只需要使用代理执行一次 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

a
a1an

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

http_proxy=hostname_or_IP:portNumber
https_proxy=hostname_or_IP:portNumber

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


R
Rahul Das

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

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


r
rashok
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


f
fiat

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

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

V
Vinoj John Hosan

在文件 ~/.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/


G
Gavin Gao

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

安装 tsocks:sudo apt install tsocks config tsocks # vi /etc/tsocks.conf server = 127.0.0.1 server_type = 5 server_port = 1080 开始:tsocks wget http://url_to_get


SOCKS 服务器不在本地子网上!失败:连接被拒绝。