Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Problem with www::mechanize Select.

by Anonymous Monk
on Nov 25, 2012 at 16:23 UTC ( #1005503=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I am trying to do a $mech->select but it is giving me an error like "Input "search_form:country_id" not found". Actually the "search_form:country_id" is present in the source code. I can not find where the Issue really is. The $mech->submit is also not submitting! Can anyone pls suggest me where i am getting wrong. The code is provided below.

use strict; use WWW::Mechanize; my $url = ""; my $mech = WWW::Mechanize->new(); print "$url\n"; eval{ $mech->agent_alias('Mac Safari'); $mech->get($url); $mech->form_name('myForm'); $mech->select('search_form:category_ext_id','0'); $mech->field('search_form:continent_id','1'); my @values = ("25","49"); $mech->select('search_form:country_id',\@values); $mech->submit(); };

Thank you all.

Replies are listed 'Best First'.
Re: Problem with www::mechanize Select. (gzip)
by tye (Sage) on Nov 25, 2012 at 20:01 UTC

    Looks to me like the problem is that the web site is sending compressed results even when the request says that compressed results are not accepted. A quick search of WWW::Mechanize documentation turned up "We add a Referer header, as well as header to note that we can accept gzip encoded content, if Compress::Zlib is installed."

    So it looks like you can fix your problem by installing the Compress::Zlib module.

    - tye        

Re: Problem with www::mechanize Select.
by Anonymous Monk on Nov 25, 2012 at 16:32 UTC
    Basically WWW::Mechanize isn't WWW::Mechanize::Firefox, one supports javascript, while the other one doesn't, the FAQ details the rest

      Is there any javascript working on that page? Can you pls suggest any other way which we can get this happen with www:mechanize only ?(by $mech->post or something?)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1005503]
Approved by moritz
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2018-06-19 05:40 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.