posting to cgi

Is there a perl module for posting to a page with cgi through a script? What I'm trying to do is fill out a form and submit it daily. Is there an easy way to do this?

Comments

  • : Is there a perl module for posting to a page with cgi through a script? What I'm trying to do is fill out a form and submit it daily. Is there an easy way to do this?
    :


    LWP::UserAgent
    and
    Net::SSLeay

    Both are pretty straightforward to use too.

    Some example code for UserAgent is below:

    my $ua = new LWP::UserAgent;
    my $req = new HTTP::Request 'POST','http://www.xxxxxxx.com/cgi-bin/xxxxx.pl';
    my $query = "var1=value1&var2=value2"; #This must be a properly URL encoded string


    $req->content_type('application/x-www-form-urlencoded');
    $req->content($query);
    my $res = $ua->request($req);

    $res->content will hold the content of the response.
    $res->is_error will be true or false depending on whether or not an error occured.

  • Big help. Thanks a bunch

    : : Is there a perl module for posting to a page with cgi through a script? What I'm trying to do is fill out a form and submit it daily. Is there an easy way to do this?
    : :
    :
    :
    : LWP::UserAgent
    : and
    : Net::SSLeay
    :
    : Both are pretty straightforward to use too.
    :
    : Some example code for UserAgent is below:
    :
    : my $ua = new LWP::UserAgent;
    : my $req = new HTTP::Request 'POST','http://www.xxxxxxx.com/cgi-bin/xxxxx.pl';
    : my $query = "var1=value1&var2=value2"; #This must be a properly URL encoded string
    :
    :
    : $req->content_type('application/x-www-form-urlencoded');
    : $req->content($query);
    : my $res = $ua->request($req);
    :
    : $res->content will hold the content of the response.
    : $res->is_error will be true or false depending on whether or not an error occured.
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories