博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
为wget使用代理
阅读量:7235 次
发布时间:2019-06-29

本文共 2975 字,大约阅读时间需要 9 分钟。

hot3.png

ubuntu-为wget使用代理

wget使用代理需要进行配置,而且目前不直接支持SOCKS5代理,需要运行辅助的软件,这里介绍有几种网上搜来的方法。不过,据试验,不是每种方法都好使,更具版本和网络环境而异,估计是这些软件都还不太成熟,只能说凑合了。

使用HTTP代理

方法一、在环境变量中设置代理

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/

 这种方式对于使用一个临时代理尤为方便。

使用SOCKS5代理

首先,使用ssh开启一个socks通道:ssh -D 8001 remote_user@remote_ip

其次,

  • 如果使用FireFox,在 “首选项-高级-网络”部分,设置 “连接-SOCKS主机”,输入127.0.0.1,端口8001,一定将DNS代理选中。
  • 也可以在系统中设置SOCKS代理服务,然后在FireFox中设置 “使用系统代理”。

如果使用wget(wget目前不直接支持SOCKS代理),参考下面:

Socksify

In order to use with a SOCKS5 proxy from , you have to install the package in order to use the SOCKS_SERVER option with the socksify utility.

sudo pkg_add dante

Subsequently, you open an SSH connection in the background:

ssh -N -C -D1080 user@hostB &

And use wget through a SOCKS5 proxy through socksify:

env SOCKS_SERVER=127.0.0.1:1080 socksify wget http://website-C

Option :

Just pipe the file to stdout on the server, and read it from stdin on your workstation.

ssh -C user@hostB "wget -O- http://website-C" >> file-from-website-C

 

ProxyChains

using (which is the newer version of ).

  1. Download, compile, and optionally install .
  2. Create a proxychains.conf file in the current directory, or at ~/.proxychains/proxychains.conf, or at /etc/proxychains.conf.
    • Alternatively, create one file anywhere else, or with another name, and specify if through -f command-line argument, or through PROXYCHAINS_CONF_FILE environment variable.
    • There is a available. The most relevant options are at the very end.
  3. In your proxychains.conf file, add:

    [ProxyList]socks5 127.0.0.1 1234
  4. Run ssh -D 1234 your_host_b. This will make ssh listen on port 1234 on localhost, and use your remote host as a SOCKS proxy.

    • Alternatively, run ssh -ND 1234 your_host_b instead. -N will prevent ssh from running any command on the remote server (i.e. it won't open a shell).
  5. Run: proxychains4 yourcommandhere yourparametershere. See some examples:
    • proxychains4 wget -O - http://ifconfig.co/
    •  
    • proxychains4 -q links http://ifconfig.co/

TSocks

  • configure tsocks, uncomment every line, except three lines below, and

lqman:~$ sudo vim /etc/tsocks.conf

server = 127.0.0.1
server_type = 5
server_port = 9999

  • Try to download with wget

lqman:~$ tsocks wget google.com

转载于:https://my.oschina.net/u/2306127/blog/791258

你可能感兴趣的文章
文件下载的ie11兼容性优化
查看>>
python写的分析mysql binlog日志工具
查看>>
MySQL 系列(二) 你不知道的数据库操作
查看>>
适配,
查看>>
缓存小姐 挡拆,网络请求 不同步 惹的祸,
查看>>
JS计算从某年某月某日到某年某月某日的间隔天数差
查看>>
使用PYTHON解析Wireshark的PCAP文件
查看>>
BarCodeToHTML(条形码toHEML)
查看>>
VC++文件监控 ReadDirectoryChangesW
查看>>
.net开发杂记
查看>>
《自动化技术中的进给电气运动》及学科学习笔记二
查看>>
所思所想目录导航
查看>>
spring中IOC模块特性
查看>>
HTML(HyperText Markup Language)
查看>>
Q&A: What is the difference between a Cash Dispersement or a Cash WithDrawal Transaction
查看>>
多线程顺序打印
查看>>
jsp九大内置对象之session和application
查看>>
codeforces 1C(几何题)
查看>>
Java集合的Stack、Queue、Map的遍历
查看>>
鼠标点击textarea后,在光标后追加内容
查看>>