我使用的是w3m。如何覆盖这个基于文本的web浏览器的用户代理?我曾尝试设置-header "User-Agent: blah“作为示例,但得到以下错误:
w3m: Can't load blah.发布于 2012-07-09 18:42:29
我通过修改文件~/.w3m/config和修改user_agent行来设置用户代理。我有以下文本,它看起来像预期的那样工作:user_agent Mozilla/5.0 (Linux i686; U; w3m 0.5.3; en)。它没有使用:或=符号,只是为了让您了解所使用的语法。
这是针对w3m版本0.5.3的。
您也可以使用w3m -header 'User-Agent: blah'设置它,但问题是它在请求中出现了两次。如果您设置了netcat“set服务器”,您可以看到w3m使用的标头:
$ netcat -lp 9999
# then in another terminal:
$ w3m -header 'User-Agent: foo' http://localhost:9999
# back at netcat:
GET / HTTP/1.0
User-Agent: w3m/0.5.3
Accept: text/html, text/*;q=0.5, image/*
Accept-Encoding: gzip, compress, bzip, bzip2, deflate
Accept-Language: en;q=1.0
Host: localhost:9999
User-Agent: foo因此,它发送2个User-Agent字符串,而实际的HTTP服务器可能无法正确解析这些字符串。
发布于 2014-03-10 22:48:31
要更新和澄清@richq的好答案中的几点:
echo 'user_agent <my-UA>' > ~/.w3m/config (在<my-UA>)
w3m whatsmyuseragent.com -dump (在屏幕上读取UA )
发布于 2019-10-09 23:47:32
w3m whatsmyua.info -o user_agent='Mozilla/5.0 (Linux i686; U; w3m 0.5.3; en)'或
echo -e '"Mozilla/5.0 (Linux i686; U; w3m 0.5.3; en)"\n"Mozilla/5.0 (Linux x86_64; U; w3m 0.5.3; en)"' >.ua
w3m whatsmyua.info -o user_agent="$(shuf -n1 .ua)"https://stackoverflow.com/questions/10257932
复制相似问题