curl-library
Re: perl script using libcurl
Date: Sun, 22 Jul 2007 14:59:32 +0200
> Does nyone have any perl script that simply uses
> libcurl to connect to a server and download the web
> page? I want to test the install of WWW-Curl and
> whether it works with Active State perl.
#!perl
# simple test script which uses the Perl5 libcurl bindings.
$myurl = $ARGV[0] || 'http://dyndns.itex.at/getip';
use WWW::Curl::Easy;
print "Perl Version: $]\n";
$mtime = (stat('/system/perl.nlm'))[9] if ($^O eq 'NetWare');
$mtime = (stat('/perl/bin/perl.exe'))[9] if ($^O eq 'MSWin32');
print "Binary Fdate: ",scalar localtime($mtime),"\n";
print "OS Name : $^O\n\n";
printf ("Curl.pm Version: %s\n", $WWW::Curl::VERSION);
printf ("Easy.pm Version: %s\n", $WWW::Curl::Easy::VERSION);
printf ("libcurl Version: %s\n\n", WWW::Curl::easy::version());
print ("=" x 78 . "\n");
my $curl = new WWW::Curl::Easy;
$curl->setopt(CURLOPT_USERAGENT, $curl->version());
$curl->setopt(CURLOPT_URL, $myurl);
$curl->perform;
my $err = $curl->errbuf;
my $info = $curl->getinfo(CURLINFO_HTTP_CODE);
print "$info\n";
print ("=" x 78 . "\n");
print "$err\n" if ($err);
have fun!
Guen.
- application/octet-stream attachment: tstcurl.pl