Grab content from Web


#1

Hi,

Are there anyone there have a solution to grab a value from Web

I call for example www.domain.com/countdown.asp?username=CrashOverride when it is below 3 I need a critical notification but if it is below 6 I only need a warning.

Are there enyone who have a solution to that ?

/CO


#2

Hi!

what I usually do is write a script that grab the whole page and do a regexp to find the desired value.

Here’s a quick example in perl, with HTTP::Lite library (search.cpan.org/~rhooper/HTTP-Lite-2.1.6/Lite.pm)

#!/usr/bin/perl

use strict;
use warnings;
use HTTP::Lite;

open STDERR, ">>/dev/null";

my $url ;
my $req ;

$url = shift @ARGV;

my $http = new HTTP::Lite;
if ( $req = $http->request("${url}") ) {
        #print "Step 1 OK \n";
} else {
        print "Impossible de charger la page\n";
        exit 0;
}
if ( $req ne "200" ) {
        print "Code retour de la page: $req\n";
        exit 2;
}

my $body = $http->body();

my $dsi_difftime;
if ( $body =~ /<dsi_difftime>(.*)<\/dsi_difftime>/) {
        $dsi_difftime = $1;
}

Hope this helps :slight_smile:


#3

Yes, thank you very much