w3m 访问不了v2ex :( - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
tshwangq
V2EX    Linux

w3m 访问不了v2ex :(

  •  
  •   tshwangq
    tshwangq Jan 19, 2013 4511 views
    This topic created in 4849 days ago, the information mentioned may be changed or developed.
    最近喜欢窝在emacs里面干所有事情。
    不过访问v2ex的时候出错了。
    显示 400 bad request ngninx/1.2.1
    7 replies    1970-01-01 08:00:00 +08:00
    arbeitandy
        1
    arbeitandy  
       Jan 19, 2013
    是因v2ex不接受空白UA
    修改 ${HOME}/.w3m/config
    找到
    user_agent
    加入一常的UA串就可以了
    tshwangq
        2
    tshwangq  
    OP
       Jan 19, 2013
    你确认么?
    我执行:

    w3m -header "User-Agent: Mozilla/5.0 (compatible; ooglebot/2.1; +http://www.google.com/bot.html)" http://v2ex.com

    依然400 bad request
    arbeitandy
        3
    arbeitandy  
       Jan 19, 2013
    -header option 只insert去,如果w3m option里有空UA串,它是覆UA配置吧。
    不我不定,但你可以用w3m的 option配置UA


    # w3m -o user_agent="" -no-proxy -dump_head http://v2ex.com
    HTTP/1.1 400 Bad Request
    Server: nginx/1.2.1
    Date: Sat, 19 Jan 2013 05:52:59 GMT
    Content-Type: text/html
    Content-Length: 172
    Connection: close

    # w3m -o user_agent="User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" -no-proxy -dump_head http://v2ex.com
    Received cookie: V2EX_LANG=en
    HTTP/1.1 200 OK
    Date: Sat, 19 Jan 2013 05:53:14 GMT
    Content-Type: text/html; charset=
    Content-Length: 0
    Connection: close
    Etag: "da39a3ee5e6b4b0d3255bfef95601890afd80709"
    Server: TornadoServer/2.4
    Set-Cookie: V2EX_LANG=en; Path=/
    arbeitandy
        4
    arbeitandy  
       Jan 19, 2013
    一念之得是不太。乾脆搜索了一下
    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"
    tshwangq
        5
    tshwangq  
    OP
       Jan 19, 2013
    多谢这么认真的探索,我现在已经可以用w3m在emacs里面访问v2ex了。
    不过.w3m/config文件似乎也没有作用。我只能在.emacs里面设置user-agent.
    Livid
        6
    Livid  
    MOD
    PRO
       Jan 19, 2013 via iPhone
    @tshwangq 看到的是移动版的页面么?
    tshwangq
        7
    tshwangq  
    OP
       Jan 19, 2013
    @Livid 普通的页面
    About     Help     Advertise     Blog     API     FAQ     Solana     2661 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 35ms UTC 02:29 PVG 10:29 LAX 19:29 JFK 22:29
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86