Jman1 has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to do some pretty simple screen-scraping, but I can't get by the login screen on Fitday.com. If I put in an incorrect username and password, I get a login error as expected, but if I put in a correct one, it keeps coming back as an invalid request. Any idea what I'm doing wrong?

(UPDATE: The error I'm receiving from $mech->res->status_line is "411 Length required.")

(Fitday accounts are free.)

#!/usr/bin/perl -w use strict; use HTTP::Cookies; use WWW::Mechanize; my $login = shift; my $password = shift; my $mech = WWW::Mechanize->new(cookie_jar => HTTP::Cookies->new); $mech->agent("Firefox/1.0"); $mech->get( 'http://www.fitday.com/' ); $mech->field( 'LoginName', $login ); $mech->field( 'Password', $password); $mech->field( 'SavePassword', 'on'); $mech->click(); print $mech->content();

Replies are listed 'Best First'.
Re: Screenscraping problem
by Happy-the-monk (Canon) on Jan 12, 2005 at 17:24 UTC

    A long shot: maybe you need to chomp() your input data to get rid of trailing newlines?

    Cheers, Sören

Re: Screenscraping problem
by Realbot (Scribe) on Jan 12, 2005 at 17:23 UTC
    I've tried your script inserting user and pw directly in the variables and it worked ok.
    Check your command line parameters...
      Hmm, no that's how I had it before I posted it here. You used a valid login/password and got to the next page?
        Yes.
        I'm using Perl v5.8.4 under Debian Sid and WWW::Mechanize 1.02
      The error I'm receiving from $mech->res->status_line is "411 Length required."
Re: Screenscraping problem
by chance (Beadle) on Jan 12, 2005 at 21:00 UTC
    get ethereal. 'eavesdrop' on yourself as you successfully login with a browser, and as your perl program fails to do so. note differences & eliminate in order of likely hood that it matters.