Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: screen scraping

by garskoci (Novice)
on Jan 08, 2005 at 19:54 UTC ( [id://420579]=note: print w/replies, xml ) Need Help??


in reply to Re: screen scraping
in thread screen scraping

Thanks for the response. I tried this bit here to log in. With different form names.
$mech->get($url); $mech->form_name( 'FVS318'); $mech->field('id', $USER); $mech->field('p',$PASS); $mech->click('submit');
But, this works. So, I can log in using the following.
my $mech = LWP::UserAgent->new; $mech->credentials( '192.168.0.1:80', 'FVS318', 'admin' => 'secret' );
I can get to the correct page, as I mentioned. So, now I will try to select and de-select the radio buttons. I have one example of selecting the radio buttons. I'll give it a whirl. Again, using the Perl modules and oo is totally new to me. Thank you.

Replies are listed 'Best First'.
Re^3: screen scraping
by Limbic~Region (Chancellor) on Jan 08, 2005 at 20:06 UTC
    garskoci,
    Are the user and pass fields form values as the WWW::Mechanize example indicates, or are they more like HTTP basic auth like the LWP::UserAgent shows? I am just guessing, but what does the following code do?
    #!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new( autocheck => 1 ); $mech->credentials( '192.168.0.1:80', 'FVS318', 'admin' => 'secret' ); # And then $mech->get() the same as in the LWP::UserAgent code
    FWIW, take a look at WWW::Mechanize::Shell as well.

    Cheers - L~R

    Update: Added a to autocheck

      I'm sorry, but like this? I get an error. Remember. Newbie. I am able to log in with the code that you provided.
      #!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new( utocheck => 1 ); $mech->credentials( '192.168.0.1:80', 'FVS318', 'admin' => 'secret' ); # And then $mech->get() the same as in the LWP::UserAgent code my $mech->get(credentials( '192.168.0.1:80', 'FVS318', 'admin' => 'secret' );
        graskoci,
        I get an error.

        In your original post you said you can not login and in this one you say you get an error. Keep in mind that we can't see what you see so in order to help we need to know what is not working, how it is not working, and what error messages you get. In this case, I believe I made a typo which you could have fixed by RTFMing. Here is the corrected code that should work.

        #!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; my $url = 'http://192.168.0.1/'; # Change if necessary my $mech = WWW::Mechanize->new( autocheck => 1 ); $mech->credentials ( '192.168.0.1:80', 'FVS318', 'admin' => 'secret' ); $mech->get( $url ); # Rest of code goes here
        Incidently, davido had an almost identical problem which you can read about here.

        Cheers - L~R

      Thank you for your help. I will work on this tomorow. I am off to a wedding. Hopefully I can make some progress and post what I have.
      Thank you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://420579]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-25 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found