Now, I think I might have a deeper understanding of the HTML:Parse module. I just needed a night to sleep and not stupify myself with the company's "Perl For Programmer's" classes that I've been in for the past few days. (Generic equivalent of "Multiplication for PHD's of Mathematics").
So here's what I hacked out.. testing it now, but since I couldn't find too many good examples off google, that I'd throw this up here and hope someone understands it better.
### # Parse the URLs my $ua = new LWP::UserAgent; $ua->agent("AgentName/0.1 " . $ua->agent); my $req = new HTTP::Request GET => $URL; $req->content_type('application/x-www-form-urlencoded'); my $res = $ua->request($req); if ($res->is_success) { $DATA = $res->content; } $WEIGHT = 1; HTML::Parser->new(api_version => 3, handlers => [start => [\&tag, "self,tagname +,attr"], end => [\&tag_end, "self,tag +name,attr"], text => [\&text, "'$WEIGHT',d +text"] ], marked_sections => 1, )->parse($DATA) || die "Huh $!\n"; .... # Parsing subroutines.. sub tag { my $self = shift; my $tagname = shift; my $attr = shift; my $stuff; $inside{$tagname} += 1; if($tagname eq "meta") { if($attr{'name'} eq ("keywords" || "description")) { $stuff = +$attr{'content'}; &text($WEIGHT,$stuff); } } elsif($tagname eq "title") { $WEIGHT = "2"; } } sub tag_end { my $self = shift; my $tagname = shift; my $attr = shift; $inside{$tagname} -= 1; if($tagname eq "title") { $WEIGHT = "1"; } } sub text { my $weight = shift; my $test_to_parse = shift; #do whatever we want to do.. }
This isn't done, but maybe it'll help someone who is looking around for this too :) thanks for all your help and suggestions.. -brad..

In reply to RE: RE: Re: Getting Words out of HTML :) by reyjrar
in thread Getting Words out of HTML :) by reyjrar

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.