gpt4 book ai didi

php - 通过 curl 和 preg_match 问题获取域到期日期/注册日期

转载 作者:搜寻专家 更新时间:2023-10-31 21:33:45 24 4
gpt4 key购买 nike

我正在尝试获取域的到期日期/注册日期,但最终得到了一个非常意外的结果,我在数组中得到了 3 个具有相同值的元素。

$domain = trim($domain); // ex google.com
$url = "http://who.is/whois/".$domain;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_exec($ch);
curl_close($ch);
$result = trim($result);
$result = preg_match('/(<span data-bind-domain="expiration_date" style="visibility: visible;">(.*?)<\/span>){1}/', $result, $matches);
var_dump($matches);

//输出

array(3) { 
[0]=> string(95) "September 14, 2020"
[1]=> string(95) "September 14, 2020"
[2]=> string(18) "September 14, 2020"
}

我正在尝试将过期日期存储到一个变量中,将注册日期存储到另一个变量中 + 前 2 个数组在只有 18 个字符时发送 95 个字符的字符串。

我错了什么

已添加

$result = preg_match('#<td><span data-bind-domain="expiration_date" style="visibility: visible;">(.*?)</span></td>#', $result, $matches);

代替

$result = preg_match('/(<span data-bind-domain="expiration_date" style="visibility: visible;">(.*?)<\/span>){1}/', $result, $matches);

现在输出很奇怪,没有说是什么类型的变量,第一个日期。2020年9月14日,没说是字符串还是数组。

最佳答案

检查一下: http://www.nott.org/blog/php-whois-script.html
一些注册商提供 API,这将使您的工作更轻松:http://opensrs.com/site/integration/api

关于php - 通过 curl 和 preg_match 问题获取域到期日期/注册日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24884083/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com