tags:

views:

42

answers:

3

my question maybe obscure but its very important for me . I have this perl code :

my $ua = LWP::UserAgent->new();
my $req = POST 'http://example.com',
[ phd => 'text' , go => 'submit'];
$content = $ua->request($req)->as_string; 
print $content;

i want send the parameter (phd => text , go => submit) with a http proxy . what am i going to do ? Thanks in Advance

+1  A: 

I wrote this a while ago when I was doing the same thing as you - http://blog.gnucom.cc/?p=122 - check it out and let me know if you find it useful (it does the same thing you're trying to do).

I think the main problem you MAY be having is that you're POST data is being sent to the wrong page. When you POST data you need to send it somewhere, like example.com/target_form.php. Your example doesn't show that you're doing that - so hope I'm not assuming too much. :D

gnucom
A: 

before you make the method call 'request' you have to add the proxy information to your UA object. Start here: http://search.cpan.org/~gaas/libwww-perl-5.836/lib/LWP/UserAgent.pm#Proxy_attributes

And is 'POST' a valid bareword operator or namespace? If not, you'll want to look into how to create a HTTP::request object first.

coffeepac
A: 

Add in an instruction so that the user agent knows the location of your proxy:

$ua->proxy("http", "http://localhost:8888");

As to the comment about POST being a valid bareword (which I probably would not have noticed), my module has something like this in it:

use HTTP::Request::Common qw( POST GET );
Auctionitis