-1

I'm trying to automate logging in to a website. The website is https://www.remind.com/log_in. Using dump_forms gives no forms on the page. I tried using this to submit the form anyway, but this fails to compile:

use strict;
use warnings;
use WWW::Mechanize;

my $ua = WWW::Mechanize -> new();
my $remind = 'https://www.remind.com/log_in';
$ua -> get ($remind);
$ua -> form_number(1);
my $uid = 'user@name.com';
$ua->field("uid", $uid );
my $password = 'passcode';
$ua->field("password", $password);

But this fails. Here is the error: Can't call method "value" on an undefined value

I'm at a loss as to what the problem is.

Aditya J.
  • 131
  • 2
  • 11
  • You should show your code using the "value" method... :-) – MarcoS Sep 14 '16 at 13:14
  • I just added my whole code so far. I don't use the "value" method. At least I think I don't – Aditya J. Sep 14 '16 at 13:18
  • Some options for Javascript are listed in [`this post`](http://stackoverflow.com/questions/12655231/cant-use-perl-wwwmechanize-to-tick-checkboxes). For one thing, [`WWW::Mechanize::Firefox`](http://search.cpan.org/~corion/WWW-Mechanize-Firefox-0.79/lib/WWW/Mechanize/Firefox.pm) that you ask about is certainly a solution -- then the browser does it for you. There's more, as well. – zdim Sep 14 '16 at 18:17
  • Firefox can autofill my username and password. I'm still having trouble finding the log in button. `click_button(n=>1)` terminates the code with this error: 3 elements found for `//*[translate(local-name(.), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") = "button" or (translate(local-name(.), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") = "input" and @type="submit")][1] at test.pl line 10.`. However, the login button as well as the "?" button are highlighted red in the tab (I used `autoclose_tab( 0 )` to observe this). – Aditya J. Sep 14 '16 at 19:48

1 Answers1

5

Probably $ua -> form_number(1); is failing, since the page you are trying to scrape (https://www.remind.com/log_in) has no forms in it...

You should analyze the page, looking at it's source code (view-source:https://www.remind.com/log_in) ... :-)

MarcoS
  • 17,323
  • 24
  • 96
  • 174