Depends how the site does userids/password.

If the login is done through a netscape-style userid/password popup then you can pass your userid & password by setting your credentials using the HTTP::Request authorization_basic method. The lwpcook documentation that comes with LWP has a good example.

If the login is done with a userid/password form and cookies, you can use the HTTP::Cookies to set up a cookiejar and then simulate your login. You set up a cookie-jar for an LWP::UserAgent as follows:

use HTTP::Cookies; my $agent = new LWP::UserAgent; my $co=new HTTP::Cookies(file=>'./stored.cookies',autosave=>1); $agent->cookie_jar($co);
Then you would do one post to "simulate" a login and get the cookies set, then just retrieve the page using $agent and all the apropriate cookies set by the login steps should be passed. Depending on how the site was written, it may take some tweaking to get this working just right.

There are other ways that sites can use to do user/password login authentication, but they are almost never user. Those two above cover about %99 of all sites that do some sort of login.


In reply to Re: Accessing web pages by lhoward
in thread Accessing web pages by Unicef2k

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.