一念之間覺得還是不太對。乾脆搜索了一下
via:
http://stackoverflow.com/questions/10257932/how-to-set-user-agent-in-w3m這裡的測試方法
* 開一個本地端口
$ netcat -lp 8000
* 使用 --header 選項配置
* 請求
# w3m -header "User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +
http://www.google.com/bot.html)" -no-proxy -dump_head http://localhost:8000
* 返回
HEAD / HTTP/1.0
User-Agent: w3m/0.5.3
Accept: text/html, text/*;q=0.5, image/*, application/*
Accept-Encoding: gzip, compress, bzip, bzip2, deflate
Accept-Language: en;q=1.0
Host: localhost:8000
User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +
http://www.google.com/bot.html)
* 使用 option 配置
* 請求
# w3m -o user_agent="(compatible; Googlebot/2.1; +
http://www.google.com/bot.html)" -no-proxy -dump_head http://localhost:8000
* 返回
HEAD / HTTP/1.0
User-Agent: (compatible; Googlebot/2.1; +
http://www.google.com/bot.html)
Accept: text/html, text/*;q=0.5, image/*, application/*
Accept-Encoding: gzip, compress, bzip, bzip2, deflate
Accept-Language: en;q=1.0
Host: localhost:8000
* 訂正一下剛才的答復:
如果用-header 加入UA,生效的實際上還是w3m的缺省UA: 第一個返回里的
User-Agent: w3m/0.5.3
並非"空白UA"