天天看點

Linux 下 Wget 設定代理

Linux進行網絡下載下傳,基本上是wget或者curl,比如我們這樣去進行請求,如果沒有代理,是通路不了的

[email protected]:/tmp$ wget google.com

--2020-03-01 11:53:14--  http://google.com/

Resolving google.com (google.com)... 46.82.174.69, 93.46.8.90

Connecting to google.com (google.com)|46.82.174.69|:80... connected.

HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.

Retrying.



--2020-03-01 11:53:15--  (try: 2)  http://google.com/

Connecting to google.com (google.com)|46.82.174.69|:80...
           

複制

是以,我們想要實作一些功能,需要為wget設定代理.方法很簡單

方法一:參數設定

wget -e http_proxy=192.168.1.8:1611 google.com



--2020-03-01 11:53:55--  http://google.com/

Connecting to 192.168.1.8:1611... connected.

Proxy request sent, awaiting response... 301 Moved Permanently

Location: http://www.google.com/ [following]

--2020-03-01 11:53:57--  http://www.google.com/

Reusing existing connection to 192.168.1.8:1611.

Proxy request sent, awaiting response... 200 OK

Length: unspecified [text/html]

Saving to: ‘index.html’



index.html                               [ <=>                                                                 ]  12.56K  --.-KB/s    in 0s



2020-03-01 11:54:01 (160 MB/s) - ‘index.html’ saved [12863]
           

複制

方法二:配置檔案設定

進入家目錄

cd ~/
           

複制

建立.wgetrc配置檔案

vim .wgetrc
           

複制

設定代理

http_proxy = http://your_proxy:port

https_proxy = http://your_proxy:port

proxy_user = user

proxy_password = password

use_proxy = on

wait = 15
           

複制

以上