Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

LWP:Simple bypass problem

by Anonymous Monk
on Jun 05, 2006 at 20:24 UTC ( #553689=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm having problems getting web pages using LWP:Simple. When I'm logged into the site and paste the url into the browser, the page comes up just fine. But when I pass the same url to 'get' command, I get the site's login page. I've used the 'get' command many times in the past and I have the username/password to this site -- is there any way to get the pages that I need instead of the login page? Has anyone worked around this?

Comment on LWP:Simple bypass problem
Re: LWP:Simple bypass problem
by davidrw (Prior) on Jun 05, 2006 at 20:33 UTC
    You could just use WWW::Mechanize (it uses LWP::Simple underneath) to login properly .. it could also be that the server is bouncing you based on your browser, in which case you can fudge the user agent string.
    use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->agent("MyApp/0.1 "); # OR: use WWW::Mechanize; my $mech = WWW::Mechanize->new( agent=>"wonderbot 1.01" );
Re: LWP:Simple bypass problem
by philcrow (Priest) on Jun 05, 2006 at 20:50 UTC
    I think you can get past basic auth by adding your username and password to the url:
    $request = HTTP::Request->new( GET => ’http://user:passwd@www.example.com/' );
    But, my memory may have failed since I last did it.

    Phil

Re: LWP:Simple bypass problem
by ioannis (Priest) on Jun 05, 2006 at 21:13 UTC
    You need the credentials() method of LWP::UserAgent; if you do this often, sub-class it into your our own Agent.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://553689]
Approved by davidrw
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2014-08-01 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls