1

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?

Borodin
  • 126,100
  • 9
  • 70
  • 144
Shiv
  • 1,211
  • 4
  • 14
  • 24
  • Related: http://stackoverflow.com/questions/3769015/how-can-i-handle-javascript-in-a-perl-web-crawler http://stackoverflow.com/questions/9559927/web-crawler-with-javascript-support-in-perl - It helps to search Stack Overflow and the Web with the relevant keywords before asking a question. – daxim Mar 09 '12 at 10:41

1 Answers1

3

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.

Richard Huxton
  • 21,516
  • 3
  • 39
  • 51