[問題] 抓回來的網頁去除html標籤後出現部份亂碼

看板Perl作者 (....N )時間17年前 (2007/12/18 13:13), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
寫了一支程式到網路上抓資料,用HTML::FormatText模組去除html標籤後會出現部份 亂碼(不是全部,甚至只有一小部份),是什麼原因呢? code如下 use LWP::UserAgent; use HTML::Parse; use HTML::FormatText; my $ua = LWP::UserAgent->new; $ua->agent("MyApp/0.1 "); my $word = '生氣'; my $response = $ua->post( 'http://www.sinica.edu.tw/ftms-bin/scripts/look_for_sym.pl', [ 'kw0' => $word ], ); if ($response->is_success) { my $res = $response->content; #$res =~s/\r\n/\n/; $ascii = HTML::FormatText->new->format(parse_html($res)); print $ascii; } else { die $response->status_line; } 印出來的部份結果如下 (1) 書卷氣 (2) 書生氣 共有2茼P義詞 為何會有小部份奇怪的亂碼呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.241.208
文章代碼(AID): #17PrRdve (Perl)
文章代碼(AID): #17PrRdve (Perl)