问题
When using wget on the console, I usually want to download the version, my Firefox would get, for ex.
wget --header="Accept: text/html" --user-agent="Mozilla/5.0 ..." --referrer connect.wso2.com http://dist.wso2.org/products/carbon/4.2.0/wso2carbon-4.2.0.zip
How can I change the default behaviour of wget
, so just using wget
would use the actual useragent and header my current Firefox is using?
(Also adding the base-URL of the downloaded site as referer would be nice)
回答1:
Create an alias like so:
alias wget='wget --header="Accept: text/html" --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0" --referrer connect.wso2.com'
You can use type
to show how your new wget
alias will be interpreted when used as a command name.
type wget
wget is aliased to `wget --header="Accept: text/html" --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0" --referrer connect.wso2.com'
来源:https://stackoverflow.com/questions/32500128/change-the-default-user-agent-and-referrer-value-in-wget