No such thing as a small change | |
PerlMonks |
Proxy using Perlby mosiurkhan (Initiate) |
on Aug 29, 2007 at 11:31 UTC ( [id://635771]=perlquestion: print w/replies, xml ) | Need Help?? |
mosiurkhan has asked for the wisdom of the Perl Monks concerning the following question:
how to proxy using LWP::userAgent?
I have written a code shown below.
But I can not set proxy using an IP from a bundle of proxy IPs.
If anybody knows, please help me.
#!/usr/bin/perl use LWP::UserAgent; use HTTP::Request; print "Content-type: text/html\n\n"; print "<html><body>"; $userIP = "123.123.123.123"; $httpReferer = "hr"; $userAgent = "ua"; $url = "http://my.website.com/abc/"; $request = HTTP::Request->new(GET=>$url); $request->referer($httpReferer); $agent = LWP::UserAgent->new(); $agent->agent($userAgent); $agent->timeout(10); $proxy = "http://" . $userIP; $agent->proxy('http',$proxy); $msResponse = $agent->request($request); $msResponse = $agent->get($url); if($msResponse->is_success) { $msContent = $msResponse->content; print $msContent; } else { print $msResponse->status_line; } - - - - - - - -- - -- - - - - - - - - - - - - - - - -
Back to
Seekers of Perl Wisdom
|
|