Linux中使用wget設定代理是如何辦到的
1、在環境變量中設定代理
直接在Linux中執行:
export http_proxy=http://127.0.0.1:8087
也可以直接修改Path檔案
Path檔案的檔案名:/.bash_profile
2、使用配置檔案
修改/etc/wgetrc,在主檔案夾下建立.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 --proxy=on/off
3、使用-e參數設定臨時代理
wget本身沒有設定代理指令的參數,但是我們可以使用-e參數,在指令行上執行一個原本出現在.wgetrc中的設定。于是可以變相在指令行上指定代理:
-e --execute=command
執行.wgetrc格式的指令
-e “https_proxy=http://127.0.0.1:8087”