langsor has asked for the wisdom of the Perl Monks concerning the following question:
use LWP::UserAgent; use HTTP::Request::Common qw(POST); $ua = LWP::UserAgent->new; $ua->agent("Mozilla/4.0 (compatible; MSIE 5.0; Windows 95)"); &ParseForm; ### this sub-routine not included here ### $input = $key{'input'}; $output = $key{'output'}; if( -r $input ){ open(IN, "<$input") || print "$!"; @list = <IN>; close(IN); }else{ print "<h3>Could not read from INPUT file</h3>"; exit; } &ParseList; exit; sub ParseList { foreach $line (@list){ my($first, $last) = split(/\|/, $line); my $content = AimAgent($first,$last); if( $content =~ /<option/gi ){ $_ = $content; while( /<option.*?value=\"(.*?)\">/gi ){ my $profile = AimAgent($first,$last,$1); PublishProfile($first,$last,$profile); ### not included ### } }else{ PublishProfile($first,$last,$content); ### not included ### } } } sub AimAgent { my($first, $last, $license) = @_; my $request = HTTP::Request->new(POST=>"http://cgi.docboard.org/cgi- +shl/nhayer.exe"); $request->content_type("application/x-www-form-urlencoded"); if( $license ){ $request->content("form_id=medname&state=na&medlname=$last&medfnam +e=$first&mednumb=$license"); }else{ $request->content("form_id=medname&state=na&medlname=$last&medfnam +e=$first"); } my $response = $ua->request($request); if( $response->is_success ){ return $response->content; }else{ return $response->status_line; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Batch process LWP search
by langsor (Novice) on Nov 05, 2005 at 01:04 UTC | |
|
Re: Batch process LWP search
by BUU (Prior) on Nov 04, 2005 at 23:42 UTC | |
|
Re: Batch process LWP search
by diotalevi (Canon) on Nov 04, 2005 at 21:35 UTC | |
|
Re: Batch process LWP search
by InfiniteSilence (Curate) on Nov 05, 2005 at 00:15 UTC |