For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > March 2004 > Perl Login to VBulletin MessageBoard









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Perl Login to VBulletin MessageBoard
Jane

2004-03-18, 6:47 pm

I'm attempting to write a script to automatically log in to a messageboard
running the VBulletin software.

First I tried this:

use HTTP::Request::Common;
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Cookies;

$ua = LWP::UserAgent->new;

#Login

my $result = $ua->request
(POST 'http://195.8.171.32/vb_forum/index.php',
[username => "<my username>",
password => "my password"]);

open(OUT, ">result.html") || print("open failed\n");

print OUT "test";

if($result->is_success) {
print OUT $result->content;
}
else {
print "Shit happens.\n";
}

close(OUT);

Unfortunately, that didn't seem to work - it didn't seem to have tried to
login at all.

So then I tried to get around the problem by logging in through by browser
and then tryin to use the cookie which should have left me logged in -
unfortunately, this didn't work either...

use HTTP::Request::Common;
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Cookies;

$cookie_jar = HTTP::Cookies::Netscape->new(
file => "C:\Documents and Settings\xxxxx\Application
Data\Phoenix\Profiles\default\c8yj3h3k.slt\cookies.txt",
) || print("Load cookie jar failed");



$ua = LWP::UserAgent->new;
$ua->cookie_jar( $cookie_jar );

my $result = $ua->request
(POST
'http://195.8.171.32/vb_forum/newthread.php?action=newthread&forumid=4',
[subject => "test",
message => "uh huh"]);

open(OUT, ">result.html") || print("open failed\n");

print OUT "test";

if($result->is_success) {
print OUT $result->content;
}
else {
print "Shit happens.\n";
}

close(OUT);

Can anyone help? Thanks!

J
Joe Smith

2004-03-18, 6:47 pm

Jane wrote:

> $cookie_jar = HTTP::Cookies::Netscape->new(
> file => "C:\Documents and Settings\xxxxx\Application
> Data\Phoenix\Profiles\default\c8yj3h3k.slt\cookies.txt",
> ) || print("Load cookie jar failed");


Use forward slashes and print the reason for failure.

my $file = "C:/Documents and Settings/xxxxx/Application
Data/Phoenix/Profiles/default/c8yj3h3k.slt/cookies.txt";
$cookie_jar = HTTP::Cookies::Netscape->new(file => $file)
or warn "Load cookie jar failed for $file $!";

-Joe
Jane

2004-03-18, 6:47 pm

Joe Smith <Joe.Smith@inwap.com> wrote in message news:<20M0c.449209$na.1090402@attbi_s04>...
> Jane wrote:
>
>
> Use forward slashes and print the reason for failure.
>
> my $file = "C:/Documents and Settings/xxxxx/Application
> Data/Phoenix/Profiles/default/c8yj3h3k.slt/cookies.txt";
> $cookie_jar = HTTP::Cookies::Netscape->new(file => $file)
> or warn "Load cookie jar failed for $file $!";
>
> -Joe


Thanks Joe - I tried this, and also tried putting random rubbish as my
path, and no fail message is generated :(.

J
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com