Methods to Submit a form with POST using {Curl | Perl | Python | Ruby | Lynx}

Assume that you have a form , in the source look for something similar to :

input name="rid"  type="TEXT"
input name="submit" value="SUBMIT" type="SUBMIT" align="center"

Then , based on your needs select any of the methods to POST the data to the form and get the required results back

Using curl :

curl -s -d "rid=value%&submit=SUBMIT" <URL> > out.html

Using Lynx to dump data :

 curl -sd 'rid=1ap05cs013&submit=SUBMIT' <URL> | lynx -dump -nolist -stdin > out.html

Using Perl :

#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
use warnings;
sub send_to {
    my $browser  = LWP::UserAgent->new;
    my $response = $browser->post(
            'rid'    => $rid,  
            'submit' => 'SUBMIT'
    print ( $response->content );

Using Python :

#!/usr/bin/env python
import urllib
# URL to post to
url = 'URL'
values = {'rid':    rid, 
            'submit': 'SUBMIT'}
html = urllib.urlopen(url, urllib.urlencode(values)).read()
print html

Using Ruby :

require "uri"
require "net/http"
uri = URI.parse('URL')
req ='URL')
  'rid'    => 'value',   
  'submit' => 'SUBMIT'
res =, uri.port).start { |http| http.request(req) }'out.htm', 'w') { |f| f.write res.body }

Share this