With the following code i want to get the url of the first link (which come 
from a query at google.com).
My target token is
<a href=http://www.hotmail.com/>
and i want to get
http://www.hotmail.com
from there, but my program get the first letter "a". I couldn't find any way 
to access the rest of the token. Any one can do that ?


#!/usr/local/bin/perl

use LWP::UserAgent;
use HTML::TokeParser;

$tokencounter=0;

print "Content-type:text/html\n\n";

$options{"agent"}="Mozilla/4.6 [en] (XII; I; SunOS 5.7 sun4u)";
my $agent=new LWP::UserAgent(%options);
$request=new HTTP::Request('GET'=>
     "http://www.google.com/search?hl=tr&q=hotmail&lr=";);
$response=$agent->request($request);
$response->is_success() || die("error".$response->status_line())."\n";

$page=new HTML::TokeParser(\($response->content()));

while($token=$page->get_token()){
  $type=shift(@$token);
  $text=shift(@$token);
  if($type eq "S" and $text eq ("p" or "P")){
    $tokencounter=$tokencounter+1;
    if($tokencounter eq 2){
      $token=$page->get_token();
      $token=$page->get_url();
      $type=shift(@$token);
      $text=shift(@$token);
      print $text;
      print "\n";
    }
  }
}



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


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

Reply via email to