Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: "Unexpected field value" error from HTTP::Headers when using WWW::Mechanize

by jbrugger (Parson)
on Mar 18, 2005 at 08:58 UTC ( [id://440642]=note: print w/replies, xml ) Need Help??


in reply to Re^2: "Unexpected field value" error from HTTP::Headers when using WWW::Mechanize
in thread "Unexpected field value" error with WWW::Mechanize

Hi, that's weird, indeed it works for me...
Is your WWW::Mechanize properly installed? my script is here
#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; use HTTP::Cookies; use Data::Dumper; my $url = 'http://search.cpan.org'; my $searchstring = 'mechanize'; my $mech = WWW::Mechanize->new(); $mech->get( $url ); if( not $mech->success() ) { print "Could not retrieve page:\n"; print $mech->content(); die; } print "all forms:\n", Dumper( [ $mech->forms ] ); $mech->submit_form( form_number => 1, fields => { query => $searchstring, } ); print "content:\n", $mech->content();
and the output is here
perl test.pl all forms: $VAR1 = [ bless( { 'enctype' => 'application/x-www-form-urlencoded', 'action' => bless( do{\(my $o = 'http://search.cpan +.org/search')}, 'URI::http' ), 'method' => 'GET', 'attr' => { 'name' => 'f', 'class' => 'searchbox', 'method' => 'get' }, 'inputs' => [ bless( { 'value_name' => 'in', 'value' => '', 'name' => 'query', 'type' => 'text', 'size' => '35' }, 'HTML::Form::TextInput' ), bless( { 'current' => 0, 'menu' => [ { 'seen' => 1, 'value' => 'al +l', 'name' => 'All +' }, { 'value' => 'mo +dule', 'name' => 'Mod +ules' }, { 'value' => 'di +st', 'name' => 'Dis +tributions' }, { 'value' => 'au +thor', 'name' => 'Aut +hors' } ], 'name' => 'mode', 'type' => 'option' }, 'HTML::Form::ListInput' ), bless( { 'value_name' => '', 'value' => 'CPAN Search', 'type' => 'submit' }, 'HTML::Form::SubmitInput' ) ] }, 'HTML::Form' ) ]; content: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859 +-1"> <link rel="stylesheet" href="/s/style.css" type="text/css"> <title>search.cpan.org: The CPAN Search Site</title> </head> <body id="cpansearch"> <center><div class="logo"><a href="/"><img src="/s/img/cpan_banner.png +" alt="CPAN"></a></div></center> <div class="menubar"> <a href="/">Home</a> &middot; <a href="/author/">Authors</a> &middot; <a href="/recent">Recent</a> &middot; <a href="/news">News</a> &middot; <a href="/mirror">Mirrors</a> &middot; <a href="/faq.html">FAQ</a> &middot; <a href="/feedback">Feedback</a> </div> <form method="get" action="/search" name="f" class="searchbox"> <input type="text" name="query" value="mechanize" size="35"> <br>in <select name="mode"> <option value="all">All</option> <option value="module" >Modules</option> <option value="dist" >Distributions</option> <option value="author" >Authors</option> </select>&nbsp;<input type="submit" value="CPAN Search"> </form> <br><div class=t4> <small> Results <b>1</b> - <b>10</b> of <b>1643</b> Found</small></div> <div class=pages><table width="100%"><tr> <td><small> <b>1</b> &middot; <a href="/search?m=all&q=mechanize&s=11">2</a> &middot; <a href="/search?m=all&q=mechanize&s=21">3</a> &middot; <a href="/search?m=all&q=mechanize&s=31">4</a> &middot; <a href="/search?m=all&q=mechanize&s=41">5</a> &middot; <a href="/search?m=all&q=mechanize&s=51">6</a> &middot; <a href="/search?m=all&q=mechanize&s=11">Next &gt;&gt;</a> </small></td> <td align=right><small><b>Page Size</b>: <a href="/search?m=all&q=mechanize&s=1&n=10">10</a>&nbsp; <a href="/search?m=all&q=mechanize&s=1&n=20">20</a>&nbsp; <a href="/search?m=all&q=mechanize&s=1&n=50">50</a>&nbsp; <a href="/search?m=all&q=mechanize&s=1&n=100">100</a>&nbsp; </small></td></tr></table> </div> <p><a href="/author/ABELTJE/Win32-IE-Mechanize-0.008/lib/Win32/IE/Me +chanize.pm"><b>Win32::IE::Mechanize</b></a> <br /><small>Like &quot;the mech&quot; but with IE as user-agent</smal +l> <br /><small> <a href="/~abeltje/Win32-IE-Mechanize-0.008/">Win32-IE +-Mechanize-0.008</a> - <span class=date>09 Jan 2005</span> - <a href="/~abeltje/">Abe Timmerman</a> </small> <p><a href="/author/CORION/WWW-Mechanize-Shell-0.36/lib/WWW/Mechaniz +e/Shell.pm"><b>WWW::Mechanize::Shell</b></a> <br /><small>An interactive shell for WWW::Mechanize</small> <br /><small> <a href="/~corion/WWW-Mechanize-Shell-0.36/">WWW-Mecha +nize-Shell-0.36</a> - <span class=date>04 Dec 2004</span> - <a href="/~corion/">Max Maischein</a> </small> <p><a href="/author/ESUMMERS/WWW-Mechanize-Sleepy-0.5/Sleepy.pm"><b> +WWW::Mechanize::Sleepy</b></a> <br /><small>A Sleepy Mechanize Agent</small> <br /><small> <a href="/~esummers/WWW-Mechanize-Sleepy-0.5/">WWW-Mec +hanize-Sleepy-0.5</a> - <span class=date>30 Aug 2003</span> - <a href="/~esummers/">Ed Summers</a> </small> <p><a href="/author/LBROCARD/WWW-Mechanize-Timed-0.42/lib/WWW/Mechan +ize/Timed.pm"><b>WWW::Mechanize::Timed</b></a> <br /><small>Time Mechanize requests</small> <br /><small> <a href="/~lbrocard/WWW-Mechanize-Timed-0.42/">WWW-Mec +hanize-Timed-0.42</a> - <span class=date>23 Jan 2004</span> - <a href="/~lbrocard/">Leon Brocard</a> </small> <p><a href="/author/CORION/Bundle-WWW-Mechanize-Shell-0.29/lib/Bundl +e/WWW/Mechanize/Shell.pm"><b>Bundle::WWW::Mechanize::Shell</b></a> <br /><small>install all optional modules for WWW::Mechanize::Shell</s +mall> <br /><small> <a href="/~corion/Bundle-WWW-Mechanize-Shell-0.29/">Bu +ndle-WWW-Mechanize-Shell-0.29</a> - <span class=date>03 Aug 2003</span> - <a href="/~corion/">Max Maischein</a> </small> <p><a href="/author/PETDANCE/WWW-Mechanize-Cached-1.32/Cached.pm"><b +>WWW::Mechanize::Cached</b></a> <br /><small>Cache response to be polite</small> <br /><small> <a href="/~petdance/WWW-Mechanize-Cached-1.32/">WWW-Me +chanize-Cached-1.32</a> - <span class=date>11 Apr 2004</span> - <a href="/~petdance/">Andy Lester</a> </small> <p><a href="/author/CORION/WWW-Mechanize-FormFiller-0.05/lib/WWW/Mec +hanize/FormFiller.pm"><b>WWW::Mechanize::FormFiller</b></a> <br /><small>framework to automate HTML forms</small> <br /><small> <a href="/~corion/WWW-Mechanize-FormFiller-0.05/">WWW- +Mechanize-FormFiller-0.05</a> - <span class=date>09 Jun 2003</span> - <a href="/~corion/">Max Maischein</a> </small> <p><a href="/author/LBROCARD/Test-WWW-Mechanize-Catalyst-0.29/lib/Te +st/WWW/Mechanize/Catalyst.pm"><b>Test::WWW::Mechanize::Catalyst</b></ +a> <br /><small> <a href="/~lbrocard/Test-WWW-Mechanize-Catalyst-0.29/" +>Test-WWW-Mechanize-Catalyst-0.29</a> - <span class=date>17 Mar 2005</span> - <a href="/~lbrocard/">Leon Brocard</a> </small> <p><a href="/author/SPOON/WWW-Yahoo-Groups-1.91/lib/WWW/Yahoo/Groups +/Mechanize.pm"><b>WWW::Yahoo::Groups::Mechanize</b></a> <br /><small>Control WWW::Mechanize for WYG.</small> <br /><small> <a href="/~spoon/WWW-Yahoo-Groups-1.91/">WWW-Yahoo-Gro +ups-1.91</a> - <span class=date>01 Dec 2003</span> - <a href="/~spoon/">Iain Truskett (see Andy Lester)</a> </small> <p><a href="/author/CPANPERL/WWW-Mechanize-Frames-0.03/lib/WWW/Mecha +nize/Frames.pm"><b>WWW::Mechanize::Frames</b></a> <br /><small> <a href="/~cpanperl/WWW-Mechanize-Frames-0.03/">WWW-Me +chanize-Frames-0.03</a> - <span class=date>17 Mar 2005</span> - <a href="/~cpanperl/">Nick Stoianov</a> </small> <br> <center> <b>1</b> &middot; <a href="/search?m=all&q=mechanize&s=11">2</a> &middot; <a href="/search?m=all&q=mechanize&s=21">3</a> &middot; <a href="/search?m=all&q=mechanize&s=31">4</a> &middot; <a href="/search?m=all&q=mechanize&s=41">5</a> &middot; <a href="/search?m=all&q=mechanize&s=51">6</a> &middot; <a href="/search?m=all&q=mechanize&s=11">Next &gt;&gt;</a> </center> <div class="footer"> hosted by <a href="http://www.perl.org/siteinfo.html">perl.org</a>, ha +rdware provided by<br/> <a href="http://www.bizrate.com"><img src="/s/img/bizrate_logo.png"></ +a> </div> <!-- Fri Mar 18 08:52:00 2005 GMT (0.671576023101807) --> </body> </html>
"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-18 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found