Saturday, 4 October 2014

Change the browser in the html header with wget

Ever wanted to download a page or make an http request with a custom header?

The parameters below let wget pretend it is a regular browser:

wget --referer="http://www.google.com" --user-agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6" --header="Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" --header="Accept-Language: en-us,en;q=0.5" --header="Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" --header="Keep-Alive: 300"   http://www.website.com/page.html
This can be useful to check e.g. if the server you're configuring blocks the right browsers and not the other ones.

Note: the blue referer lets you specify the page you were previously on.