Scripts for Article on Adapting Forms.
#!/usr/bin/perl -w # This program, locis.pl is a perl script for retrieving information from the # Library of Congress Online Catalog. Spider removed not included. # Copyright David Novak, The Spire Project Aug 7th, 1997. #### # Define Variables $doc=""; #### # Start Program ### Establish our Agent !!! ... missing lines for the spider ... if ($ENV{REQUEST_METHOD} eq 'GET') { $result=$ENV{'QUERY_STRING'}; } else {exit;} $result =~ tr/+/ /; $result =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $result =~ s/ /+/g; $result =~ s/\&remove=//g; $doc = &fetch; # $doc now is the webpage text if ($doc eq 0) { print ("Location: http://catalog.loc.gov/cgi-bin/Pwebrecon.cgi?DB=local&PAGE=cbSearch\n\n"); exit; } $doc =~ m!<INPUT TYPE=HIDDEN NAME=PID VALUE="(.*?)">!i; $searchid = '&PID=' . $1; $doc =~ m!<INPUT TYPE=HIDDEN NAME=SEQ VALUE="(.*?)">!i; $searchid2 = '&SEQ=' . $1; $destination = "http://catalog.loc.gov/cgi-bin/Pwebrecon.cgi?" . $result . $searchid . $searchid2 . "&HIST=1&CNT=25+records+per+screen" . "\n\n"; print ("Location: $destination"); # print ("Content-type: text/html\n\n"); # print "$destination"; exit; ##### # Subroutines sub fetch { my($url) = "http://catalog.loc.gov/cgi-bin/Pwebrecon.cgi?DB=local&PAGE=cbSearch"; my $request = new HTTP::Request('GET', $url); my $response = $ua->request($request); if ($response->is_success) { #fetch was successful return($response->content); } else {return(0);} } | |||
The Spire Project - better ways to find information. Like this? You should attend our public seminar and receive our bi-monthly update notice. | SpireProject.com | SpireProject.co.uk | Project Background | Feedback. Copyright©David Novak 2002. |