Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: TokeParser and newlines

by suaveant (Parson)
on Aug 02, 2012 at 00:27 UTC ( #984923=note: print w/ replies, xml ) Need Help??

in reply to TokeParser and newlines

Well, this isn't exactly right but it'll move you along, don't have time to continue. Probably finding a more comprehensive parser as previously suggested would help

#!/usr/bin/perl -w use strict; use LWP::Simple; use HTML::TokeParser; my $url = ' +D=12700&SPID=5671&SPSID=53628'; my $raw = get($url); my $stream = HTML::TokeParser->new(\$raw) or die "$url $!"; while(my $token = $stream->get_token() ) { my $ttype = shift @{ $token }; if ($ttype eq "S") { my($tag, $attr, $attrseq, $rawtxt) = @{ $token }; next until ($tag eq "table"); my $class = $attr->{'class'}; if ($class eq "ScheduleTable") { while($stream->get_tag('tr')) {# my $sched = $stream->get_trimmed_text('/tr'); print "$sched\n"; } } # class eq "ScheduleTable" } # $ttype eq "S" } # while

                - Ant
                - Some of my best work - (1 2 3)

Comment on Re: TokeParser and newlines
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://984923]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2015-10-13 12:12 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (304 votes), past polls