Oh beloved, worshipped, sacred, holy Monks: I have written a script to grab a www page. I have to pass cookies in order to get the page. I can successfully get it, but it seems the cookies arent being used properly. I have asked around among all the perl people I know, but no one can answer this for me.
Can anyone find any problems in this code? The cookies file is correct and standardized... looks like this:
#LWP-Cookies-1.0
Set-Cookie3: id=bob_loblaw; path="/"; domain=yoursite.here.com; path_s
+pec; expires="2005-12-31 23:59:33Z"; version=0
Set-Cookie3: username=blahblahblah; path="/"; domain=yoursite.here.com
+; path_spec; expires="2015-11-06 08:09:49Z"; version=0
--------------------------
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Cookies;
my $rssFile = "dump.rss";
my $wwwSite = "www.your.site.here.com";
my $cookieFile = "c:/cookies.txt";
my $browser = LWP::UserAgent->new;
$browser->timeout(10);
$browser->env_proxy;
$browser->cookie_jar(HTTP::Cookies->new(file => $cookieFile ));
my $response = $browser->get( $wwwSite );
if ($response->is_success) {
open RSSDUMP, ">" . $rssFile;
print RSSDUMP $response->content;
close RSSDUMP;
}
else {
die $response->status_line;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|