in reply to Re: HTML::TokeParser help - parsing headlines
in thread HTML::TokeParser help - parsing headlines

Hey,

I adjusted my code correctly to extract the urls from the reauters headlines.

However, when printing out the urls it looks like:

http://www.reuters.com/newsArticle.jhtml;jsessionid=1GRGO0RUSCREMCRBAE +0CFFA?type=businessNews&storyID=4512094告on=news http://www.reuters.com/newsArticle.jhtml;jsessionid=1GRGO0RUSCREMCRBAE +0CFFA?type=businessNews&storyID=4512054告on=news http://www.reuters.com/newsArticle.jhtml;jsessionid=1GRGO0RUSCREMCRBAE +0CFFA?type=businessNews&storyID=4512041告on=news
If you copy and paste one of those url's, it will bring you to a blank reuters template, part being because at the end part of the url where it has "告on=news", should really be "'&'section=news".

Somehow its translating the "'&'section=news" into "告on=news".

Could it be because I'm using MIME-Base32 and not MIME-Base64 module? --I'm on a Windows machine.

Adjusted code:
#!/usr/bin/perl -w use strict; use HTML::TokeParser; use LWP::Simple; use URI; print "Content-type: text/html\n\n"; my $filename = 'temp.html'; open FH, ">$filename"; print FH get("http://www.reuters.com/newsEarlierArticles.jhtml?type=bu +sinessNews"); close FH; my $stream = HTML::TokeParser->new($filename) || die "Couldn't read HTML file $filename: $!"; while(my $token = $stream->get_token) { if ($token->[0] eq 'S' and $token->[1] eq 'td' and ($token->[2]{'class'} || '') eq 'earlyHeadline') { my(@next) = ($stream->get_token); if ($next[0] and $next[0][0] eq 'S' and $next[0][1] eq 'a' and defined + $next[0][2]{'href'} ) { #early headline found for business section/grab a href portion print URI->new_abs($next[0][2]{'href'}, 'http://www.reuter +s.com/'), "\n"; } } }
Thank you,
Anthony