Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

LWP and HTTP::Cookies Trouble

0 views
Skip to first unread message

Superkuh

unread,
Jan 5, 2003, 7:31:09 PM1/5/03
to begi...@perl.org

I've been having a bit of trouble getting LWP and HTTP::Cookies to play
nice in a little script I've been making. Basically it's just a simple
get client that retrieves a series of URLs defined by 2 for loops. But
to achieve it's goal the client has too both impersonate a browser
(which was quite easy thanks to LWP) and accept cookies, which I thought
HTTP cookies working in concert with LWP could handle. But for some odd
reason I can't get the silly little script to work. No cookies are
recieved by the client, and thus the server I'm playing around with does
not perform the action I wanted.

So why doesn't this accept cookies?
-------------------------------------------------------

use LWP::UserAgent;
use HTTP::Request::Common qw(GET);
use HTTP::Cookies;

$line = "";
$agtname = q[Mozilla/5.0 (compatible; Konqueror/3.0.0-10; Linux)];
@headers = (
'Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*',
'Accept-Charset' => 'iso-8859-1,*,utf-8',
'Accept-Language' => 'en-US',
'Referer' => "http:\/\/www.superkuh.com\/"
);

system ("cls");
print "Operation ChunkBuster Commencing\n";
print "--------------------------------\n\n";

for ($x = 200; $x <= 320; $x++) {
for ($y = 22; $y <= 47; $y++) {
$line = 'http://drunkmenworkhere.org/189.php?x=' . "$x" . '&y=' . "$y";
$url = "$line";

$ua = LWP::UserAgent->new('agent' => $agtname);
$ua->cookie_jar(HTTP::Cookies->new(file => "cookies.txt", autosave => 1));

# $ua->cookie_jar({});
push(@{ $ua->requests_redirectable }, 'POST');

$req = GET ($url, @headers);
print $ua->request($req)->as_string;
print "\n\n";
sleep 1.2;
}
}

--
Superkuh <supe...@attbi.com>
http://www.superkuh.com/

0 new messages