This will extract the text and uses HTML::TokeParser::Simple which is a wrapper around HTML::Parser. I've add white space to the HTML for clarity.
#! /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>
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
One of the anchor tags has an email address as the href attribute. Do you need to collect that as well?

In reply to Re: Parsing with HTML::TreeBuilder::LibXML on OpenSuse Linux 11.4 Milestone 1 by wfsp
in thread Parsing with HTML::TreeBuilder::LibXML on OpenSuse Linux 11.4 Milestone 1 by Perlbeginner1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.