Get current URL with WWW :: Mechanize PERL

1

Can you help me get the current URL where I am located (after login)?

use strict;
use WWW::Mechanize;
use HTTP::Cookies;

my $urlActual;
my $url = "xxxxxxxxxxxxxx";
my $palabra;
my $username = 'xxxxxxxxxx';
my $password = 'xxxxxxxxxxxxx';

my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);
$mech->form_name('menubar_login');
$mech->field(txt_login => $username);
$mech->field(txt_clave => $password);
$mech->click();
my $app_content = $mech->content();

$urlActual = top.frame.location.href
Printf($urlActual)

I miss an error in the penultimate line.


Edited: And after receiving some answers about using $mech->uri() , I find the error:

    
asked by Javier 18.01.2017 в 12:48
source

3 answers

1

As it comes in your documentation:

  

$mech->uri()

     

Returns the current URI as a URI object.

Reference to the documentation

    
answered by 18.01.2017 в 13:05
1

The error message indicates that you are missing a semicolon ( ; ) on line 18.

Solution: $mech->uri(); (add semicolon)

    
answered by 18.01.2017 в 17:15
1

The last two lines do not follow the Perl syntax. They look more like JavaScript.

You must use the uri () method.

    
answered by 25.01.2017 в 13:46