- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试获取域的到期日期/注册日期,但最终得到了一个非常意外的结果,我在数组中得到了 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/
我想知道我们是否可以替换 if(preg_match('/boo/', $anything) 和 preg_match('/poo/', $anything)) 用正则表达式.. $anything
假设字符串是: $a = "abc-def" if (preg_match("/[^a-z0-9]/i", $a, $m)){ $i = "i stopped scanning '$a' beca
好的,所以我希望用户能够输入 A-Z 中的每个字符和 0-9 中的每个数字,但我不希望他们输入“特殊字符”。 代码: if (preg_match("/^[a-zA-Z0-9]$/", $user_n
我想使用 preg_match 来查找括号之间的文本,例如:$varx = "(xx)"; 最终输出将是 $match = 'xx'; 另一个例子$varx = "bla bla (yy) bla b
嘿伙计们,我正在尝试删除最后一个 _1.jpg 如果它存在于我的表达中,但我遇到了一些麻烦 场景如下。 image_name_1.jpg(应该是image_name.jpg) image_name_1
我需要修复这个 preg_match("/^[[0-9]{0,4}$/i", $input),它还需要接受负值。谢谢 最佳答案 if (preg_match('/^-?[0-9]{1,4}$/', $
我正在尝试提出一个符合 25 的正则表达式在这个字符串中: Always - 25 (Lifetime - 之间的空间量和 25可以是可变的,但尾随 (Lifetime将永远在
我试图通过仅过滤掉符合以下条件的单词来匹配字符串中的关键字: 任何地方都有大写字母的单词,例如“iPhone”或“camelCase” 连续大写的词组,例如“Pittsburgh Steelers”或
我在 mysql 字段中有此数据: First text text text text text text text text text text text text text text tex
我有这个代码 preg_match("/\bHTTP(.)+ (\d{3})/", $string) 在最后一个模式中,我必须检查一个可以由任何数字组成但不应该创建像 404 或 401 这样的数字的
你好,我想匹配下一行中的“@”, create@create_time:"2012-05-30 21:14:35.0",update_time:"2012-05-31 22:05:46.0" preg
我使用“或”运算符“|”只匹配 $name 变量的单词 $name = "one five six two"; if (preg_match('/(one|two)/i', $name)) {retu
大家好 我有一个字符串 Open Directory Sites (1-20 of 10000) 我需要得到 10000 作为答案.. 我如何使用 preg_match ???注意:这是重要的,匹配的
我想使用 preg_match 为带括号的子模式返回每个匹配项的数组。 我有这个代码: $input = '[one][two][three]'; if ( preg_match('/
我有一个像这样值的变量: $sentence = "When it comes time to renew your auto insurance policy, be aware of how yo
我只想允许使用字母、数字、空格、无色线和连字符。 到目前为止,我认为这个 preg_match 可以完成这项工作: if(preg_match('/[^a-z0-9 _]+$/i', $name))
这个问题与this直接相关我大约 15 分钟前提出的问题。这不是要与那个帖子重复,而是希望这更多是一种学习经验。 在提出的问题中,我试图找出导致 preg_match no deliminator f
我有以下字符串 № покупки(OrderId) : 12345 Доп.Информация 1 : Имя Доп.Информация 2 : Уставная деятельность 我
我正在尝试为我们的防火墙创建报告功能。 防火墙规则以 json 格式存储。 这是字符串的示例。 [{"id":1,"enabled":true,"description":"TEMP","matche
在多个模式的情况下,可以在相同的数组索引下返回 preg_match 的结果。我的意思是我有以下 preg_match 什么正在检查不同子字符串( '&q' 、 '?q' 、 '&keywords'
我是一名优秀的程序员,十分优秀!