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:

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:

$ ./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. $

Source, with the critical line tried several different ways:

#! /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.p +l line 21. # your first guess...aka trial 2 # my @date_fields =$mech->selector( './/*[@name="date"]', node => $sel +f->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/loc +al/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 => $sel +f->current_form ]' # 5th guess my @date_fields =$mech->selector( './/*[@name="date", node => $mech->c +urrent_form ]'); # Invalid rule, couldn't parse '//*[@name="date", node => $mech->curre +nt_form ]' $mech->set_field( $date_fields[1] => $guess ); $mech->click_button( value => "Update" ); # this seems similar to W +M say "clickbutton succeeded" if $mech->success(); my $string = $mech->uri; say ("We are at $string") if $mech->success();

That lays it out there as starkly as I can. VielenDank und Gruss aus Amiland.


In reply to Re^4: running an example script with WWW::Mechanize* module by Aldebaran
in thread running an example script with WWW::Mechanize* module by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.