Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default user agent in Wget

I want to know what default user agent is passed if I use wget from command line without specifying explicit user agent.

I have some code which cahnges output based on user agent .

wget http://www.google.com -O test.html
like image 585
TopCoder Avatar asked Oct 06 '10 11:10

TopCoder


People also ask

What is a wget user agent?

“User-Agent” is a header field that the browser sends to the server it wants to access. Therefore, to download from a server that is refusing to connect, try to modify the user agent. Find a database of all user agents online, search for the one you need and run the command: wget --user-agent="User Agent Here" "[URL]"

How does wget command work?

Wget is a networking command-line tool that lets you download files and interact with REST APIs. It supports the HTTP , HTTPS , FTP , and FTPS internet protocols. Wget can deal with unstable and slow network connections. In the event of a download failure, Wget keeps trying until the entire file has been retrieved.


2 Answers

"wget -d" will show the request made to the server.

$ wget -d http://www.google.com -O/dev/null 2>&1 |grep ^User-Agent
User-Agent: Wget/1.13.4 (linux-gnu)
User-Agent: Wget/1.13.4 (linux-gnu)
User-Agent: Wget/1.13.4 (linux-gnu)
like image 79
Giuseppe Scrivano Avatar answered Oct 28 '22 23:10

Giuseppe Scrivano


At your shell prompt, do:

> man wget

scroll down to -U agent-string, which states:

"Wget normally identifies as Wget/version, version being the current version number of Wget".

So do:

> wget --version

which will give you the version, and thus your user-agent.

Incidently, you may find that some sites block wget, so depending on what you're doing you may need to change this.

like image 34
Richard H Avatar answered Oct 28 '22 23:10

Richard H