Default user agent in Wget
I want to kno开发者_运维问答w 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
"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)
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.
On my Fedora 13 system, it shows Wget/1.12 (linux-gnu)
Run wget and sniff the communication.
You can also check the web server's log, usually it containts the user agent of the connecting clients.
This is what i got off the latest wget for windows: Wget/1.11.4
You could verify this with a network protocol analyzer such as Wireshark. With Wireshark you can inspect the headers and every other detail of the whole protocol stack involved.
Wireshark is both free and open source: http://www.wireshark.org/
精彩评论