1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#!/usr/bin/perl
use LWP::Simple qw(get);
use LWP::UserAgent;
$PROXY="";
$PROTOCOLE="";
$TIMEOUT="";
$APPARENCE="";
$LOGIN="";
$PASSWORD="";
$AUTHENTIFY=0;
$MODE=0;
print "\nQuel phone number voulez vous tester ?\n";
chomp($PHONE_NUMBER = <stdin>);
$URL ="http://www.agence.francetelecom.com/servlet/ftbynet_adsl.Gp_GetReponseADSL?Support=".$PHONE_NUMBER."&OffreADSL=IPW1E";
@CONTENTANDBASE = OpenDoc($URL,$MODE,$PROXY,$TIMEOUT,$PROTOCOLE,$APPARENCE,$AUTHENTIFY,$LOGIN,$PASSWORD);
$CONTENT=@CONTENTANDBASE[1];
@LINES = split( "\n", $CONTENT);
foreach (@LINES) {
if ( $_=~ m!.+<strong>(.+)<br>! ) {
$STATUS=$1;
if ($STATUS=~ /Votre ligne est compatible avec l´ADSL,/) {
$ELIGIBILITE="OUI";
}
elsif ($STATUS=~ /A ce jour, l´ADSL n´est pas/ ) {
$ELIGIBILITE="NON";
}
print qq($PHONE_NUMBER\t$ELIGIBILITE\n);
}
}
#########################################################################################
# Telecharge la réponse d'une URL. Deux modes, avec ou sans proxy
#########################################################################################
sub OpenDoc {
my $url=@_[0];
my $mode=@_[1];
my $proxy=@_[2];
my $timeout=@_[3];
my $protocole=@_[4];
my $apparence=@_[5];
my $authentify=@_[6];
my $login=@_[7];
my $password=@_[8];
my @contentAndBase;
my $base;
my $content;
my $header;
my $browser = LWP::UserAgent->new();
$browser->agent($apparence);
$browser->timeout($timeout);
if ($mode==1) {
$browser->proxy($protocole,$proxy);
}
my $request = HTTP::Request->new(GET => $url);
if ($authentify==1) {
$request->authorization_basic ("$login","$password");
}
my $response= $browser->request($request);
if ($response->is_error()) {
print FILELOG "Error with $url: " . $response->status_line . "\n";
print "ETL Error with $url\n" . $response->status_line . "\n";
$content= "ETL Error with $url\n" . $response->status_line . "\n";
$base= "";
$header="";
}
else {
$content=$response->content();
$base=$response->base;
$header=$response->header(content_type);
}
push (@contentAndBase,$base);
push (@contentAndBase,$content);
push (@contentAndBase,$header);
return @contentAndBase;
} |