Shiv
Shiv

Reputation: 1241

Getting error in accessing a link using WWW::Mechanize

Getting the following error in a JavaScript link using perl - WWW::Mechanize.

Error GETing javascript:submt_os('2','contact%20info','contact%20info'):Protocol scheme 'javascript' is not supported

This is my code:

#!/usr/bin/perl
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();

$uri="http://tinyurl.com/76xv4ld";
$mech->get($uri);

# error on this link
$mech->follow_link( text => 'Contact Information');

print $mech->content();

Once I get the page, I want to click Contact Information.

Is there any other way to click Contact Information?

Upvotes: 1

Views: 743

Answers (1)

Richard Huxton
Richard Huxton

Reputation: 22893

You can't follow a javascript link with WWW::Mechanize. Even if you had a javascript interpreter you'd need complete DOM support for anything non-trivial.

So - you need to script a web-browser. I use Selenium in my testing, which is quite bulky and requires java. You might want to investigate WWW::Mechanize::Firefox. I've not used it but it does provide a mechanize style interface to Firefox.

Upvotes: 3

Related Questions