私はRIPE IPアドレス範囲からのwhoisレコードのうち、descr:
で始まる行の内容を取得したいので、彼らはすべて次のようになります。PHPで特定の文字列を含むファイルから行を解析するには? PHPで
% This is RIPE NCC's Routing Information Service
% whois gateway to collected BGP Routing Tables
% IPv4 or IPv6 address to origin prefix match
%
% For more information visit http://www.ripe.net/ris/riswhois.html
route: 53.0.0.0/8
origin: AS31399
descr: DAIMLER-AS Daimler Autonomous System
lastupd-frst: 2011-12-08 23:18Z [email protected]
lastupd-last: 2012-01-25 15:18Z [email protected]
seen-at: rrc00,rrc01,rrc03,rrc04,rrc05,rrc07,rrc10,rrc11,rrc12,rrc13,rrc14,rrc15,rrc16
num-rispeers: 98
source: RISWHOIS
だから私はとしてDAIMLER-AS Daimler Autonomous System
を取得する必要があります結果。
これを最低限のコードで実行するには、$ whoisにレコードがあります。
<?php
$whois = shell_exec('whois -h riswhois.ripe.net ' . $ip);
?>
whoisコマンドを実行するためにPHPからシェルを外さないでください。あなたのプログラムの中でwhoisクエリを行うか、ポート43のTCPソケットを開いて、すべての詳細についてはRFC3912を読むために、PHPに特定のライブラリがあります。 –