I'll ignore your arrogant assertion regarding my diagnostic abilities. I've done the research on google and on irc before posting the node, so take those comments elsewhere, they aren't helpful.
A slightly more-condensed example (using Encode as you suggested) also fails.
I'll keep debugging to find out how to work around this. The site is definately switching on the UserAgent value sent in the request, but without relying on HTML::Entities to encode the whole lot, it doesn't like what it gets from Encode::CN here.
use strict; # use LWP::Debug qw(+); use LWP::UserAgent; use XML::LibXML; use Encode qw/encode decode/; my $url = 'http://www.cboe.com/Chinese'; my $ua = 'Mozilla/5.0 (en-US; rv:1.4b) Gecko/20030514'; my $browser = LWP::UserAgent->new( agent => "$ua"); my $response = $browser->get($url); my $content = $response->content; print "Cleaning $url...\n"; # gb2312-raw also fails my $euc_cn = encode("euc-cn", $content); my $utf8 = decode("euc-cn", $euc_cn); clean_html($euc_cn); sub clean_html { my $input = shift; my $p = XML::LibXML->new(); # parser $p->recover(1); my $cleaned = $p->parse_html_string($input)->toStringHTML; }
In reply to Re: Crashing XML::LibXML by setting UserAgent
by hacker
in thread Crashing XML::LibXML by setting UserAgent
by hacker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |