Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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
[zentara]: I'm listening to 20,000 Tibetan monks chant Om Mani Padme Hum
[zentara]: I've decided the first words I will utter when I'm born into that other world..... Hari Om :-)
[LanX]: I forgot my mantra

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2017-05-24 21:45 GMT
Find Nodes?
    Voting Booth?