note
Aldebaran
<i>The form is not great, because it really contains three fields with the same name date, so you will have to fetch the individual fields and explicitly set them:</i>
<p>Thanks, [Corion], I think we're almost there. I've got this pared down as far as I can to make an SSCCE. I can't get perl to think I have a valid selector:</p>
<c>$ ./6.1.pluto.pl
say (...) interpreted as function at ./6.1.pluto.pl line 47.
2020/04/20 20:10:39 Connected to ws://127.0.0.1:40757/devtools/browser/10f7d706-4dbd-4073-a438-916f6602fb4c
found the one and only form
Invalid rule, couldn't parse '//*[@name="date", node => $mech->current_form ]' at /usr/local/share/perl/5.26.1/HTML/Selector/XPath.pm line 283.
$
</c>
<p>Source, with the critical line tried several different ways:</p>
<c>#! /usr/bin/perl
use warnings;
use strict;
use WWW::Mechanize::Chrome;
use Log::Log4perl qw(:easy);
use Data::Dump;
use 5.016;
Log::Log4perl->easy_init($INFO);
my $site =
'https://www.fourmilab.ch/cgi-bin/Yoursky?z=1&lat=45.5183&ns=North&lon=122.676&ew=West';
my $mech = WWW::Mechanize::Chrome->new( headless => 1, );
$mech->get($site);
my $guess = 2458960; #Earth day 2020 in julian days
$mech->form_number(1);
say "found the one and only form"
if $mech->success();
# my best guess...aka...trial 1
# $mech->field( date => '2', jd => $guess );
# stderr: 3 elements found for input with name 'date' at ./6.1.pluto.pl line 21.
# your first guess...aka trial 2
# my @date_fields =$mech->selector( './/*[@name="date"]', node => $self->current_form );
# stderr: Global symbol "$self" requires explicit package name
# 3rd guess
#my @date_fields =$mech->selector( './/*[@name="date"]', node => $mech->current_form );
# stderr: Invalid rule, couldn't parse '//*[@name="date"]' at /usr/local/share/perl/5.26.1/HTML/Selector/XPath.pm line 283.
# 4th guess
# my @date_fields =$mech->selector( './/*[@name="date", node => $self->current_form ]');
# stderr: Invalid rule, couldn't parse '//*[@name="date", node => $self->current_form ]'
# 5th guess
my @date_fields =$mech->selector( './/*[@name="date", node => $mech->current_form ]');
# Invalid rule, couldn't parse '//*[@name="date", node => $mech->current_form ]'
$mech->set_field( $date_fields[1] => $guess );
$mech->click_button( value => "Update" ); # this seems similar to WM
say "clickbutton succeeded"
if $mech->success();
my $string = $mech->uri;
say ("We are at $string")
if $mech->success();
</c>
<p>That lays it out there as starkly as I can. VielenDank und Gruss aus Amiland.</p>
11115421
11115779