Passing username and password using LWP::UserAgent

N

neo

Hi,
I ve written a perl script which sends the user name and password
through a proxy for authentication,the problem is that after it is
getting authenticated it is not showing the contents of the desired
page i.e the page which the user wants to visit is not being displayed

code


use LWP::UserAgent;


$ua = new LWP::UserAgent;


$ua->proxy(['http'] => '<http://abc.com:389>');


$req = new HTTP::Request 'GET','http://xyz.com';


$req->proxy_authorization_basic('username','password');


$res = $ua->request($req);


print $res->content if $res->is_success;
print $ua->request($req)->as_string;


code


the problem with the above code is that it does not directs the user to

'http://xyz.com" after authentication can anybody help me out please..
 
K

kill bill

Hi Gunnar,
I'm sorry if i ve multi-posted d same query.I wnt do it in future.If
you could help me out i'll appreciate that.

thanks
bill
 
N

neo

Hi,
Thanks for replying buddy but the code u gave did not work could please
let me know how to use WWW::Mechanize

Thanks
neo said:
Hi,
I ve written a perl script which sends the user name and password
through a proxy for authentication,the problem is that after it is
getting authenticated it is not showing the contents of the desired
page i.e the page which the user wants to visit is not being displayed
They probably use cookies, try below, or if that fails, use
WWW::Mechanize
code
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->proxy(['http'] => '<http://abc.com:389>');

use HTTP::Cookies;
my $cookies = new HTTP::Cookies();
$ua->cookie_jar($cookies);

$req = new HTTP::Request 'GET','http://xyz.com';
$req->proxy_authorization_basic('username','password');
$res = $ua->request($req);
print $res->content if $res->is_success;
print $ua->request($req)->as_string;
code
 
Z

zentara

Hi,
Thanks for replying buddy but the code u gave did not work could please
let me know how to use WWW::Mechanize

There is no one way to use Mechanize, it's almost an art.

Your best bet is to look at the Cookbook of examples that
come with the module, and do a google and groups.google
search for some keywords, like
"WWW::Mechanize proxy"
and you will find alot of code snippets.

http://perlmonks.org?node_id=588880
or
http://www.developer.com/lang/other/article.php/10942_3454041_2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top