From: Ryan Davis Date: 2010-06-11T18:27:03+09:00 Subject: Re: Mechanize output:strange number On Jun 10, 2010, at 17:55 , Pen Ttt wrote: > require 'mechanize' > agent = WWW::Mechanize.new > page = > agent.get('http://hd.openv.com/tv_play-hddoc_20090703_7064487.html') > > > i get the following output: > > # "\347\210\261\345\215\241\346\261\275\350\275\246" > "http://newcar.xcar.com.cn/"> > # "58\347\224\237\346\264\273\345\234\210" > "http://q.58.com/"> > # "\345\207\244\345\207\260\345\233\275\346\227\205" > "http://www.51tour.com/"> > # "\351\236\255\347\211\233\345\243\253" > "http://www.bianews.com/"> > # "\345\244\232\347\216\251\346\270\270\346\210\217\347\275\221" > "http://www.duowan.com/"> > # "\344\271\220\351\200\224\346\227\205\346\270\270\347\275\221" > > > what is the meanning of > "\347\210\261\345\215\241\346\261\275\350\275\246"? With `curl -I $url` you can quickly see that the page is encoded UTF-8. If you take off the "-I" you can see the content. In my terminal, it displays very prettily: >
Discovery全球首选绿住家
You're probably running your script with the default ASCII encoding. Try this out: > ruby -KU -rubygems -e 'require "mechanize"; p Mechanize.new.get("http://hd.openv.com/tv_play-hddoc_20090703_7064487.html").links'