#!/usr/bin/env perl # # formfind.pl # # This script gets a HTML page from the specified URL and presents form # information you may need in order to machine-make a respond to the form. # # Written to use 'curl' for URL fetching. # # Author: Daniel Stenberg # Version: 0.2 Nov 18, 2002 # # HISTORY # # 0.1 - Nov 12 1998 - Created now! # 0.2 - Nov 18 2002 - Enhanced. Removed URL support, use only stdin. # $in=""; $usestdin = 1; if($ARGV[0] eq "-h") { print "Usage: $0 < HTML\n"; exit; } # If you need a proxy for web access, edit your .curlrc file to feature # -x # linkchecker, URL will be appended to the right of this command line # this is the one using HEAD: $linkcheck = "curl -s -m 20 -I"; # as a second attempt, this will be used. This is not using HEAD but will # get the whole frigging document! $linkcheckfull = "curl -s -m 20 -i"; # htmlget, URL will be appended to the right of this command line $htmlget = "curl -s"; # urlget, URL will be appended to the right of this command line # this stores the file with the remote file name in the current dir $urlget = "curl -O -s"; sub namevalue { my ($tag)=@_; my $name=$tag; if($name =~ /name *=/i) { $name=~ s/.*name *= *(\"|)([^ \">]*).*/$2/gi; } else { # no name given $name=""; } # get value tag my $value= $tag; if($value =~ /value *=/i) { $value=~ s/.*value *= *(\"|)([^ \">]*).*/$2/gi; } else { $value=""; } return ($name, $value); } while() { $line = $_; push @indoc, $line; $line=~ s/\n//g; $line=~ s/\r//g; $in=$in.$line; } while($in =~ /[^<]*(<[^>]+>)/g ) { # we have a tag in $1 $tag = $1; if($tag =~ /^