Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^2: WWW::Mechanize - Could not connect to a server

by jesuashok (Curate)
on Mar 21, 2007 at 02:09 UTC ( #605781=note: print w/replies, xml ) Need Help??

in reply to Re: WWW::Mechanize - Could not connect to a server
in thread WWW::Mechanize - Could not connect to a server


#!/usr/bin/perl -w use WWW::Mechanize; use strict; use Data::Dumper; use Storable; my $url = ' +0027.html'; my $m = WWW::Mechanize->new(); $m->http_proxy ( "proxy_address:proxy_port" );
I tried the above code and got the error as follows :-
Can't locate object method "http_proxy" via package "WWW::Mechanize" a +t lin e 11.
Is there something wrong in the above Code. If so, could you add your valuable points.

hmmm ....let me think what did I said

Replies are listed 'Best First'.
Re^3: WWW::Mechanize - Could not connect to a server
by marto (Bishop) on Mar 21, 2007 at 09:07 UTC
    If you had read the Documentation (which was pointed out to you by chargrill in the first reply to this thread) you would see that you have $m->http_proxy rather than $m->proxy. Again, if you are not sure about something why not read the documentation, it does not take that long does it?

    As a side note you can also use can to find out if a Method exists within an invocant:
    #!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); if ($mech->can("http_proxy")){ print "Mech can http_proxy\n"; }else{ print "Mech can't http_proxy\n"; } if ($mech->can("proxy")){ print "Mech can proxy\n"; }else{ print "Mech can't proxy\n"; }

    Hope this helps

      To be fair, I also hadn't done an RTFM before posting, which is why I commented on the error. Then again, I'm not the one having problems with my code :)
        No harm done I guess, they would not sell pencils with erasers at one end if nobody ever made a mistake :) When possible I try and test the code I post to make sure that it works as I claim it will.


Re^3: WWW::Mechanize - Could not connect to a server
by Anonymous Monk on Mar 21, 2007 at 03:47 UTC
    There is no method http_proxy. If you RTFM you can discover the correct method.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://605781]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2017-12-16 16:59 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (457 votes). Check out past polls.