I'm using w3m. How do I go about overriding the user agent of this text based web browser? I have tried setting -header "User-Agent: blah" as an example, but I get the following error:
w3m: Can't load blah.
To update and clarify a few points from @richq's good answer:
A quick, one-liner to set the UA is:
echo 'user_agent <my-UA>' > ~/.w3m/config
(Paste desired UA over <my-UA>
)
And the much easier way to check the received UA is to simply grab one of the free UA site pages, Ex.
w3m whatsmyuseragent.com -dump
(Read UA on screen.)
I set the User-Agent by modifying the file
~/.w3m/config
and modifying theuser_agent
line. I have the following text and it seems to work as expected:user_agent Mozilla/5.0 (Linux i686; U; w3m 0.5.3; en)
. That has no : or = signs in it, just so you get an idea of the syntax used.This is with w3m version 0.5.3.
You can also set it with
w3m -header 'User-Agent: blah'
but the problem there is that it appears twice in the request. You can see the headers that w3m uses if you set up a netcat "webserver":So it sends 2 User-Agent strings, which may not be parsed correctly by the real HTTP server.