Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: WWW::Mechanize input value

by Athanasius (Archbishop)
on Aug 04, 2012 at 14:40 UTC ( [id://985438]=note: print w/replies, xml ) Need Help??


in reply to WWW::Mechanize input value

Hello packetstormer,

The WWW::Mechanize->field method is actually for setting the field value. Your first call sets the value of 'sessionid' to undef (since no second argument is supplied), and returns the previous value. Your second call gets the new, empty value.

Use the WWW::Mechanize->value method instead. This gets the field value without the side effect of resetting it:

my $mech = WWW::Mechanize->new(agent => 'Windows IE 6'); my $url = "https://www.somesite.com"; $mech->get($url); print "Value: '", $mech->value('sessionid'), "'\n"; my $sessionid = $mech->value('sessionid'); print "\$sessionid = '$sessionid'\n";

See WWW::Mechanize, under “FIELD METHODS.”

HTH,

Athanasius <°(((><contra mundum

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-19 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found