[Buffalo-pm] LWP help request

Rob Raux rjraux at cse.Buffalo.EDU
Thu Jul 31 11:47:36 CDT 2003


I threw together a brief little example of using WWW::Mechanize to get
right into your minutes.  All you need to do is regex the actual data out
of the page... perhaps taking a look at HTML::TokeParse.

Any questions, feel free to ask.

Rob

---- CUT -----
#!/usr/bin/perl -w

use strict;

use WWW::Mechanize;

my $PHONE = '5555555555';
my $PASS  = 'iamgod';

my $agent = WWW::Mechanize->new();
$agent->get("http://www.sprintpcs.com/");
$agent->form(1);

$agent->field("min", $PHONE);
$agent->field("password", $PASS);
$agent->click();

$agent->follow_link( url =>
'https://manage1.sprintpcs.com/Manage?target=MyCurrentUsage&action=current_usage');

#this will print you the page you want,
#now you just need to get the data in a form you want... regex?
print $agent->{content};

----------

On Thu, 31 Jul 2003, Jason Parker-Burlingham wrote:

> Jesse L Farinacci <jlf27 at cse.Buffalo.EDU> writes:
>
> > my $url = 'https://manage1.sprintpcs.com/Manage?target=MyCurrentUsage&action=current_usage';
> > my $ua = LWP::UserAgent->new;
> > my $req = HTTP::Request->new(GET => $url);
> > $req->authorization_basic(PHONE_NBR, PASSWORD);
> > my $res = $ua->request($req);
>
> I think I *do* remember some problems getting basic authorization
> working over HTTPS some years ago when I was working on a HotMail
> harvester.  Sadly I seem to have deleted that project.
>
> > i've got the LWP with SSL properly configured, i've tested this out with
> > other https pages and it's working fine.
>
> I assume the other pages don't use basic authorization?  Could you set
> up a small test area to work with?
>
> > i'm not sure if it is even possible for me to POST to the main page,
> > then while still within that UserAgent to request the usage page ::
> > perhaps the uname / pword authentication will have passed from the
> > POST and remain within the context of the UA??  maybe i'm grasping
> > at straws..
>
> You *may* want to have a look at the WWW::Mechanize::Shell module from
> CPAN.  I've been toying with it for the last few hours and have been
> having pretty good success, although...  Well.  Here's the problem:
>
>    [0]henry at freezer:henry $ perl -MWWW::Mechanize::Shell -eshell
>    Module File::Modified not found. Automatic reloading disabled.
>    >get http://heavens-above.com/
>    Retrieving http://heavens-above.com/(200)
>    http://heavens-above.com/>links
>    [0] Return to main menu page
>    [1] Advertisement
>    [2] here
>    [3] here
>    [4] log-on
>    [5] Register
>    [6] Select
>    [7] Enter
>    [8] Chris Peat
>    [9] FAQ
>    [10] GSOC Home Page
>    http://heavens-above.com/>open 4
>    (200)
>    http://heavens-above.com/logon.asp>forms
>    Form [1]
>    POST http://heavens-above.com/processlogon.asp
>      UserName=<UNDEF>                (textbox)
>      Password=                       (password)
>      Remember=<UNDEF>                (checkbox) [*<UNDEF>|1]
>      <NONAME>=Submit                 (submit)
>    http://heavens-above.com/logon.asp>fillout
>    (textbox)UserName> [] nooks
>    (password)Password> [] NotMyPassword
>    |1
>    (checkbox)Remember> [] 1
>    http://heavens-above.com/logon.asp>submit
>    200
>    http://heavens-above.com/logon.asp?Err=ZeroLenUser>
>
> For some reason trying to set the UserName parameter doesn't seem to
> be sent to the server correctly.  But this sounds like a pretty bad
> failure of WWW::Mechanize::Shell.  I'm checking the module is properly
> installed now but I wonder if any list members have ideas?
>
> jason
> --
> Stay up-to-date on what I'm doing lately:
>                                  http://www.panix.com/~jasonp
> _______________________________________________
> Buffalo-pm mailing list
> Buffalo-pm at mail.pm.org
> http://mail.pm.org/mailman/listinfo/buffalo-pm
>




More information about the Buffalo-pm mailing list