Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: How to do CGI POST as client? - solved

From: dud:monmouth at: 15-Dec-2000 10:15

After a lot of false starts trying to get Rebol to successfully do a CGI POST operation, I finally figured out how to write a script that works. Bill Dudley P.S. I don't think Rebol is ready for prime time if the examples in the Core book don't all run correctly. Working script: #!/usr/local/bin/perl use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->agent("AgentName/0.1 " . $ua->agent); @sites= ( "", ); $data = "npa=\"732\"&nxx=\"842\"&process=Lookup"; foreach $url (@sites) { my $req = new HTTP::Request POST => $url; $req->content_type('application/x-www-form-urlencoded'); $req->content($data); my $res = $ua->request($req); if($res->is_success) { $res->content =~ s/<[^<>]*>//g; $res->content =~ s/^[ ]*\n//mg; print "$res->content"; } else { print "didn't work:\n$url $data\n"; } }