Can Perl be used for this?

Discussion in 'Perl' started by GC, Jul 30, 2003.

  1. GC

    GC Guest

    GC, Jul 30, 2003
    #1
    1. Advertising

  2. GC

    Claus Guest

    GC <> wrote in message news:<>...
    > Hi,
    >
    > I'm looking for a solution to capture the data on a web page with 2
    > buttons, send & receive threads of this URL
    > http://atlantis.b-rail.be:8880/atlantis/SilverStream/Pages/PM_GalileoLog.html.
    > It would be nice to gather both pages and dump them into a MySql database.
    > Do you think Perl would be suitable for this and what's the direction I
    > need to take to build this script?
    >
    > Geert


    I use perl for this kind of stuff all the time. It's very simple.

    use
    LWP to handle the web interaction (see example below)
    HTML::Form to deal with automatic form submission
    DBI to deal with MySQL

    Claus

    Minimal LWP/HTML::Form example:
    use strict;
    use LWP::UserAgent;
    use HTTP::Request;
    use HTML::Form;

    my $url = 'http://someurl';

    #Setup your client - the UserAgent
    my $ua = LWP::UserAgent->new;
    # To be nice, set your agent string:
    $ua->agent('LWP');
    #This page uses GET
    my $req = HTTP::Request->new(GET=>$url);
    my $res = $ua->request($req);
    if (not $res->is_success) {
    die "no page found\n";
    }
    #Parse the result with HTML::Form
    # You can set form values and also 'press buttons'
    my $form = HTML::Form->parse($res->content, $url);
    my $result = $ua->request($form->click);
    Claus, Aug 8, 2003
    #2
    1. Advertising

  3. GC

    GC Guest

    Are there more examples available somewhere?



    Claus wrote:
    > GC <> wrote in message news:<>...
    >
    >>Hi,
    >>
    >>I'm looking for a solution to capture the data on a web page with 2
    >>buttons, send & receive threads of this URL
    >>http://atlantis.b-rail.be:8880/atlantis/SilverStream/Pages/PM_GalileoLog.html.
    >>It would be nice to gather both pages and dump them into a MySql database.
    >>Do you think Perl would be suitable for this and what's the direction I
    >>need to take to build this script?
    >>
    >>Geert

    >
    >
    > I use perl for this kind of stuff all the time. It's very simple.
    >
    > use
    > LWP to handle the web interaction (see example below)
    > HTML::Form to deal with automatic form submission
    > DBI to deal with MySQL
    >
    > Claus
    >
    > Minimal LWP/HTML::Form example:
    > use strict;
    > use LWP::UserAgent;
    > use HTTP::Request;
    > use HTML::Form;
    >
    > my $url = 'http://someurl';
    >
    > #Setup your client - the UserAgent
    > my $ua = LWP::UserAgent->new;
    > # To be nice, set your agent string:
    > $ua->agent('LWP');
    > #This page uses GET
    > my $req = HTTP::Request->new(GET=>$url);
    > my $res = $ua->request($req);
    > if (not $res->is_success) {
    > die "no page found\n";
    > }
    > #Parse the result with HTML::Form
    > # You can set form values and also 'press buttons'
    > my $form = HTML::Form->parse($res->content, $url);
    > my $result = $ua->request($form->click);
    GC, Sep 2, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Casey Hawthorne
    Replies:
    1
    Views:
    700
    Arne Vajhøj
    Mar 18, 2009
  2. Guy
    Replies:
    6
    Views:
    245
    Ben Morrow
    Dec 5, 2003
  3. Martin

    Can an .OCX be used in Perl?

    Martin, Dec 3, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    113
    Martin
    Dec 4, 2003
  4. garey
    Replies:
    3
    Views:
    154
    Joe Smith
    May 29, 2007
  5. Ted Byers
    Replies:
    23
    Views:
    412
    Peter J. Holzer
    Nov 15, 2008
Loading...

Share This Page