0
我想构建制表符分隔的数据文件。我使用正则表达式来提取所需的信息,即注册人名称,注册人电子邮件和域名。我希望以制表符分隔的格式为每个域查找代码输出结果。你能给我提示我如何能做到这一点?正则表达式和制表符分隔的数据文件
<?php
require 'Net/Whois.php';
$server = 'whois.networksolutions.com';
$content=file('query-file.txt');
foreach ($content as $query)
{
$whois = new Net_Whois;
$data = $whois->query($query, $server);
if (preg_match_all('/^registrant name: (.*)/im', $data, $matches, PREG_SET_ORDER))
// Print the matches:
{
echo '<pre>' . $matches[0][1] . '</pre>';
} else {
echo 'not found!</p>';
}
if (preg_match_all('/^registrant email: (.*)/im', $data, $email, PREG_SET_ORDER))
// Print the matches:
{
echo '<pre>' . $email[0][1] . '</pre>';
} else {
echo 'not found!</p>';
}
if (preg_match_all('/^Domain Name: (.*)/im', $data, $email, PREG_SET_ORDER))
// Print the matches:
{
echo '<pre>' . $email[0][1] . '</pre>';
} else {
echo 'not found!</p>';
}
}
?>
输出的代码的
Dns Admin
[email protected]
google.com
not found!
not found!
not found!
Domain Name Manager
[email protected]
cnn.com
Domain Administrator
[email protected]
msn.com
Domain Administrator
[email protected]
hotmail.com
Domain Administrator
[email protected]
yahoo.com
DNS Admin
[email protected]
gmail.com
期望的输出应该像
Dns Admin [email protected] google.com
Domain Name Manager [email protected] cnn.com
Domain Administrator [email protected] msn.com
...