Php 使用google检查url,safe=active

Php 使用google检查url,safe=active,php,curl,Php,Curl,如何检查url是否由google显示 例如: https://www.google.com/search?q=redtubex.xxx&safe=active 代码: $input='1!'http://www.example.com'; $input=修剪($input,“/”); 如果(!preg_match(“#^http(s)”://,$input)) { $input='http://'。$input; } $urlParts=parse_url($input); $doma

如何检查url是否由google显示

例如:

https://www.google.com/search?q=redtubex.xxx&safe=active
代码:

$input='1!'http://www.example.com';
$input=修剪($input,“/”);
如果(!preg_match(“#^http(s)”://,$input))
{
$input='http://'。$input;
}
$urlParts=parse_url($input);
$domain=preg_replace(“/^www./”,“$urlParts['host']);
$request='1https://www.google.com/search?q=“.$domain.&safe=active/”;
$ch=curl\u init($request);
curl_setopt($ch,CURLOPT_头,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$data=curl\u exec($ch);
curl_exec($ch);
卷曲关闭($ch);
preg_match_all(“/(.*?/”,$data,$matches);
foreach($匹配为$fmatch)
{
echo$fmatch[1]);
}

curl\u exec($ch)
echo curl\u getinfo($ch)之后
使用此函数可以获得您的curl成功运行或未成功运行的信息,我有结果,但如果url是否由google显示,我需要确切的信息。@rafig您所说的google显示的
是什么意思?请参见上面的示例。如果safe=active,您在google serps中看不到redbutex.xxx。您有解决方案吗?
$input = 'http://www.example.com';
$input = trim($input, '/');
if (!preg_match('#^http(s)?://#', $input))
{
     $input = 'http://' . $input;
}

$urlParts = parse_url($input);
$domain = preg_replace('/^www\./', '', $urlParts['host']);
$request = 'https://www.google.com/search?q='.$domain.'&safe=active/';

$ch = curl_init($request);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_exec($ch);
curl_close($ch);

preg_match_all('/<cite.*?>(.*?)<\/cite>/', $data, $matches); 
foreach ($matches as $fmatch)
{
    echo $fmatch[1]);
}