Hi All.

I have a script that goes to google. Performs a search. I have a regular 
expression that gets all the links. The first link in the array I return is 
ment to open the next page. But it keeps failing with an error stating it is 
illegal page. When I try and use lwp, it says you cannot use an absolute link. 
But the link looks fine to myself.

Below is the code, any help on resolving this issue would be great. The goal of 
the script is to input a movie name. find the details of the movie from 
imbd.com. Then save it as a text file. Eventually this Information will be 
turned into a web page. 

So when I want to watch a movie at home. I can identify the movie rating, what 
it is about, etc.

This is a Work in progress script.

#!/usr/bin/perl

# finding description and category for movies.

# Initialise moduels.
use strict;
use warnings;
use URI;
use LWP::UserAgent;
use HTML::TreeBuilder 3;  # make sure our version isn't ancient
use WWW::Mechanize;

my $dirname = 'T:\\new movies';
my @movies;
my $url = 'http://www.google.com.au';


open (FP, "<", "t:\\movies.txt") || die "could not find";
my $m = WWW::Mechanize->new();
$m->get($url);

while (<FP>) {
chomp;
#print "file: $_\n";

$m->form_name('f');
$m->field('q', ('imdb.com: ' . $_));
my $response = $m->submit();

my @links = $m->find_all_links( url_regex => qr/www\.imdb\.com\/title\// ); 

my $link = $links[0]->url;
my $text = $links[0]->text;
print "$_\t$text\t$link\n";
my $browser = LWP::UserAgent->new(  );
my $response = $browser->get($link);
die "Hmm, error \"", $response->status_line(  ),
my $content = $response->content(  );

}

Note, I have used $m->get ($link); as well with no success and even the 
$m->follow-link method.

Sean 

Reply via email to