LWP to fill in forms: "Cookies are not Enabled on your Browser"

K

Kyri

Hi Everyone,

I'm writing a program that fills in the username and password field on
www.facebook.com/login.php and hits submit.
The forms fill out correctly and the button is hit correctly.
However, I get an error page when my program tries to log in. It has
the message:

"Cookies are not enabled on your browser. Please adjust this in your
security preferences before continuing."

Here is that portion of my code:

# Author: Kyri Baker
# 2007/06/05

use Tk;
use LWP;
use HTTP::Cookies;
use POSIX;
use strict;
require Tk::DialogBox;
require LWP::UserAgent;

my $ua = LWP::UserAgent->new;
$ua->cookie_jar( HTTP::Cookies->new() );
$ua->timeout(10);
$ua->env_proxy;
$ua->agent('Mozilla/5.0');


my $email='(e-mail address removed)';
my $pass='MY_PASSWORD';
my $action = 'Login';
my $response = $ua->post('http://www.facebook.com/login.php',['email'=>
$email, 'pass'=>$pass, 'doquicklogin'=>$action]);

print $response->content;
 
B

Brad Baxter

Hi Everyone,

I'm writing a program that fills in the username and password field onwww.facebook.com/login.phpand hits submit.
The forms fill out correctly and the button is hit correctly.
However, I get an error page when my program tries to log in. It has
the message:

"Cookies are not enabled on your browser. Please adjust this in your
security preferences before continuing."

Here is that portion of my code:

# Author: Kyri Baker
# 2007/06/05

use Tk;
use LWP;
use HTTP::Cookies;
use POSIX;
use strict;
require Tk::DialogBox;
require LWP::UserAgent;

my $ua = LWP::UserAgent->new;
$ua->cookie_jar( HTTP::Cookies->new() );
$ua->timeout(10);
$ua->env_proxy;
$ua->agent('Mozilla/5.0');

my $email='(e-mail address removed)';
my $pass='MY_PASSWORD';
my $action = 'Login';
my $response = $ua->post('http://www.facebook.com/login.php',['email'=>
$email, 'pass'=>$pass, 'doquicklogin'=>$action]);

print $response->content;

The cookie jar needs a file, e.g.,

my $cjar = "/tmp/bmb_lwpcookies.txt"; # yours will be different
my $ua = LWP::UserAgent->new(cookie_jar=>{file=>$cjar,autosave=>1});

But I haven't tested your script to see if this is the actual/only
problem.
 
K

Kyri

Hi Everyone,
I'm writing a program that fills in the username and password field onwww.facebook.com/login.phpandhits submit.
The forms fill out correctly and the button is hit correctly.
However, I get an error page when my program tries to log in. It has
the message:
"Cookies are not enabled on your browser. Please adjust this in your
security preferences before continuing."
Here is that portion of my code:
# Author: Kyri Baker
# 2007/06/05
use Tk;
use LWP;
use HTTP::Cookies;
use POSIX;
use strict;
require Tk::DialogBox;
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->cookie_jar( HTTP::Cookies->new() );
$ua->timeout(10);
$ua->env_proxy;
$ua->agent('Mozilla/5.0');
my $email='(e-mail address removed)';
my $pass='MY_PASSWORD';
my $action = 'Login';
my $response = $ua->post('http://www.facebook.com/login.php',['email'=>
$email, 'pass'=>$pass, 'doquicklogin'=>$action]);
print $response->content;

The cookie jar needs a file, e.g.,

my $cjar = "/tmp/bmb_lwpcookies.txt"; # yours will be different
my $ua = LWP::UserAgent->new(cookie_jar=>{file=>$cjar,autosave=>1});

But I haven't tested your script to see if this is the actual/only
problem.

Ah...thank you. This is a very ignorant question, but I currently
have cookies.txt as a blank text file and my program errors saying
"cookies.txt does not seem to contain cookies" - Am I supposed to be
sending my browser cookies?!
 
B

Brad Baxter

Ah...thank you. This is a very ignorant question, but I currently
have cookies.txt as a blank text file and my program errors saying
"cookies.txt does not seem to contain cookies" - Am I supposed to be
sending my browser cookies?!

I guess I would try deleting that file and letting your program create
it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,732
Latest member
ArronPalin

Latest Threads

Top