如何查看是否谷歌显示网址?
示例:
https://www.google.com/search?q=redtubex.xxx&safe=active
代码:
$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]);
}