using scripting languages to automate a browser [message #180398] |
Sun, 10 February 2013 08:04 |
Cal Dershowitz
Messages: 36 Registered: February 2013
Karma:
|
Member |
|
|
Hello newsgroup,
I've been trying to use perl to automate processes that aren't much more
than a few GUI events that a person would do if he had a browser.
#!/usr/bin/perl -w
use strict;
use autodie;
use utf8;
use WWW::Mechanize;
my $url = 'http://translate.google.com/';
my $mech = WWW::Mechanize->new;
my $result = $mech->get($url);
die "GET failedn" unless $result->is_success;
my $filename = 'content1.txt';
$mech->save_content($filename);
my @links = $mech->links();
print "tags\n";
print $_->tag()."\n" foreach @links;
print "URI\n";
print $_->URI()."\n" foreach @links;
print "text\n";
print $_->text()."\n" foreach @links;
print "forms\n";
my @forms = $mech->forms();
# print $_->text()."\n" foreach @forms;
$mech->current_form()
With the amount of difficulty that this has presented itself to be, I've
started to wonder whether I'm not using a wrench to pound a nail. What
I'm trying to do in this instance is to click a button to turn the
language, enter the text that I would have in a file, click translate,
and capture the output.
Is this something that php can do in a way that involves less grief?
Thanks for your comment, and cheers.
--
Cal Dershowitz
|
|
|