如何使用PHP计算谷歌反向链接

web*_*kul 6 php

我想创建自己的使用PHP进行反向链接计算的工具.是否有任何api to fetech反向链接的数据

Ard*_* Xi 4

PHP 中的完整实现如下所示:

<?php
$domain = "example.com"; // Enter your domain here.

$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&"
    . "q=link:".$domain;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $domain);
$body = curl_exec($ch);
curl_close($ch);

$json = json_decode($body);
$urls = array();
foreach($json->responseData->results as $result) // Loop through the objects in the result
    $urls[] = $result->unescapedUrl;             // and add the URL to the array.
?>
Run Code Online (Sandbox Code Playgroud)

基本上,您在顶部编辑域变量,它将$urls用链接到域的未转义 URL 填充数组。

编辑:我已编辑链接以返回 8 个结果。如需更多信息,您必须解析页面并使用 start 参数循环遍历它们。有关详细信息,请参阅类参考。