Hi Chris and list,

I went ahead and started using HTML::TokeParser and I have read the
HTML::TokeParser manpage.  I am sure my coding is correct but for some
reason the script always returns this error...

Can't call method "get_tag" on an undefined value at
/var/www/cgi-bin/<nameofscript> line 321.

Here is how the code looks...

  $inputSite = "URL OF CHOICE";
  $tree = HTML::TreeBuilder->new;
  $address = "http://"; . $inputSite;
  $request = HTTP::Request->new('GET', $address);
  $response = $ua->request($request);
  my $found = 0;

  my $content = $address;

  $p = HTML::TokeParser->new(shift||$content);
  if ($p->get_tag("title")) {
      my $title = $p->get_trimmed_text;
      print "Title: $title\n";
  }

Can any one see anything wrong with this?

Thx,

Dan

-----Original Message-----
From: Chris Ball [mailto:[EMAIL PROTECTED]]
Sent: Friday, 22 February 2002 9:49 PM
To: Daniel Falkenberg
Cc: [EMAIL PROTECTED]
Subject: Re: What would take care of this?...


>>>>> "Daniel" == Daniel Falkenberg <[EMAIL PROTECTED]> writes:

    Daniel> Would I now have to go ahead and use HTML::parser or
    Daniel> something of similar nature to extract headings?

Yeah, go with HTML::TokeParser.

    Daniel> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
    Daniel> <HTML><HEAD><TITLE>Get all data from H1</TITLE> </HEAD><BODY
    Daniel> BGCOLOR="FFFFFF"><h1>I want all if this data extracted from
    Daniel> heading 1 (h1)</h1> </BODY></HTML>

while ($stream->get_tag("h1")) { $data = get_trimmed_text("/h1"); }

(Also see perldoc HTML::TokeParser, once it's installed.)

- Chris.
-- 
$a="printf.net"; Chris Ball | chris@void.$a | www.$a | finger: chris@$a
         "In the beginning there was nothing, which exploded."


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to