in reply to How to submit hidden forms

Here's what I would do.

1. Download the page with the form you want to your computer.

2. Delete the part in the form where it says action="example.php (or whatever)" and put in "formpairs.pl (saved in the same location or whatever)". The script below is formpairs.pl.

#!/usr/bin/perl # formpairs.pl - extract names and values from HTTP requests use strict; use warnings; my $data; if(! $ENV{'REQUEST_METHOD'}) { # not run as a CGI die "Usage: $0 \"url\"\n" unless $ARGV[0]; $data = $ARGV[0]; $data = $1 if $data =~ s/^\w+\:.*?\?(.+)//; print "Data from that URL:\n(\n"; } elsif($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $data, $ENV{'CONTENT_LENGTH'}); print "Content-type: text/plain\n\nPOST data:\n(\n"; } else { $data = $ENV{'QUERY_STRING'}; print "Content-type: text/plain\n\nGET data:\n(\n"; } for (split '&', $data, -1) { # Assumes proper URLencoded input tr/+/ /; s/"/\\"/g; s/=/\" => \"/; s/%20/ /g; s/%/\\x/g; # so %0d => \x0d print " \"$_\",\n"; } print ")\n"; __END__

3. Open the page up in your browser locally, and then run the code by submitting the form.

4. This should show you what values you need in your form.

Also check out Perl & LWP by Sean Burke. That's where this code was taken from.

From there I use $mech->set_fields(); to input the form info.

Have fun spamming Myspace! ;)

Replies are listed 'Best First'.
Re^2: How to submit hidden forms
by Anonymous Monk on Feb 01, 2007 at 20:24 UTC
    Very nice, Thanks!