I have a website which is located in the local server.
Now, with browser it generally gives a
prompt in form
of popup for us to fill in user name and password.
Following
Corion's advice.
I tried to mimic the process with this
following Perl script, especially with WWW::Mechanize
credentials method.
use WWW::Mechanize;
my $addr = 'http://myhost.com.sg/cgi-bin/biobase/transfac/9.4/bin/star
+t.cgi';
my $username = 'myname';
my $pwd = 'somepassword';
my $mech = WWW::Mechanize->new();
$mech->get($addr);
$mech->credentials($username,$pwd);
my $result = $mech->content();
print "$result\n";
But it gives:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Authorization Required</title>
</head><body>
<h1>Authorization Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
<hr />
<address>Apache/2.0.46 (Red Hat) Server at myhost.com.sg Port 80</addr
+ess>
</body></html>
Did I use the right module and its method?
How can I know what kind of cookie they are using?
So that I can know which is the right module and method to use? Because I can't seem to figure out the cookie setting
by looking at the source code of that link.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.