开发者

Posting parameter with Proxy (perl)

I want to send the parameter (phd => text , go => submit) with a http proxy. How can I do this?

I have this Perl code:

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


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 );


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜