in reply to Parsing with HTML::TreeBuilder::LibXML on OpenSuse Linux 11.4 Milestone 1
#! /usr/bin/perl use strict; use warnings; use HTML::TokeParser::Simple; my $p = HTML::TokeParser::Simple->new(*DATA) or die qq{cant parse html: $!\n}; my @text; while (my $t = $p->get_token){ next unless $t->is_text; my $txt = $t->as_is; if ($txt =~ /Hit/ .. $txt =~ /Listed since/){ for ($txt){ s/^\s+//; s/\s+$//; } next unless $txt; push @text, $txt; } } print qq{$_\n} for @text; __DATA__ <br><br> <h2>Hit 7 out of 120517</h2> <img src="http://myweb.org/images/wappen/ni.gif" class="wappen_pos" width="45" height="53" alt="country" title="countryname" /> <br> <div style="width: 40em;"><br> <div style="display: inline;"> <div class="logo_homepage"> <a class="img_inl" href="http://myWeb.org/222237520031111" > </a> </div> <br> <div class="fm_linkeSpalte"> <h2>name 1</h2> <br> <span class="schulart_text">type: one (for example)</span> <p class="einzel_text"> Adress: Paris, 3ne Boulevard Saint Lo<br /><br> Telefon:048 + 334555664 , Fax: 048 + 334555667<br /> MyWeb-Nummer: 222237520031111 <br /> Webmaster: <a href="mailto: webmaster@demosite.fr" class="p1" > master </a> <br /> </p> </div> <div> <p class="ta_left einzel_text"></p> </div> <br /> <div> <p class="ta_left einzel_text">Listed since: 20.08.2002</p> </div> <br><br><br><br>
One of the anchor tags has an email address as the href attribute. Do you need to collect that as well?Hit 7 out of 120517 name 1 type: one (for example) Adress: Paris, 3ne Boulevard Saint Lo Telefon:048 + 334555664 , Fax: 048 + 334555667 MyWeb-Nummer: 222237520031111 Webmaster: master Listed since: 20.08.2002
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
[Re7]: Parsing with HTML::TreeBuilder::LibXML on OpenSuse Linux 11.4 Milestone 1
by Perlbeginner1 (Scribe) on Sep 26, 2010 at 12:03 UTC | |
by bart (Canon) on Sep 26, 2010 at 13:25 UTC | |
by wfsp (Abbot) on Sep 26, 2010 at 13:51 UTC | |
by Perlbeginner1 (Scribe) on Sep 26, 2010 at 18:45 UTC |