Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: running an example script with WWW::Mechanize* module

by Corion (Patriarch)
on Apr 21, 2020 at 06:07 UTC ( [id://11115857]=note: print w/replies, xml ) Need Help??


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

Invalid rule, couldn't parse '//*[@name="date", node => $mech->current +_form ]'

This looks as if you're mixing Perl code and an XPath expression in the same string.

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.

This is weird - I think this should still parse as an XPath expression. Does the following work and give the expected result?

my @date_fields =$mech->xpath( './/*[@name="date"]', node => $mech->c +urrent_form );

With version 0.48 of WWW::Mechanize::Chrome, ->set_fields now also supports selecing input elements by their name and index:

$mech->set_fields( date => [3, $date_value], );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11115857]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-25 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found