Google endeksli sayfaların sayısını bulmak için bir PHP komut dosyası yazmak için nasıl?

3 Cevap

Ben belirli bir etki alanı adı için google endekslenmiş sayfaların sayısını, bir PHP komut dosyası aracılığıyla bunu nasıl yapacağız bulmak gerekir?

Bu yüzden,

    foreach ($allresponseresults as $responseresult)
    {
        $result[] = array(
            'url' => $responseresult['url'],
            'title' => $responseresult['title'],
            'abstract' => $responseresult['content'],
        );
    }

what do i add for the estimated number of results and how do i do that? i know it is (estimatedResultCount) but how do i add that? and i call the title for example this way: $result['title'] so how to get the number and how to print the number?

Thank you :)

3 Cevap

Ben onların sığınakta Arama API kullanmak için Google'a güzel olacağını düşünüyorum. Bir örnek çağrı için bu URL'yi bakınız:

http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site:stackoverflow.com&filter=0

(Sen estimatedResultCount değer ilgilendiğiniz)

PHP Eğer file_get_contents to get the data and json_decode bunu ayrıştırmak için kullanabilirsiniz.

Sen belgeleri burada bulabilirsiniz:

http://code.google.com/apis/ajaxsearch/documentation/#fonje


Example

Warning: Aşağıdaki kod hata yanıtı denetimini her türlü yok!

function getGoogleCount($domain) {
    $content = file_get_contents('http://ajax.googleapis.com/ajax/services/' .
        'search/web?v=1.0&filter=0&q=site:' . urlencode($domain));
    $data = json_decode($content);
    return intval($data->responseData->cursor->estimatedResultCount);
}

echo getGoogleCount('stackoverflow.com');

Sen cURL ile http://www.google.com/search?q=domaingoeshere.com yüklemek ve ardından sonuçları <p id="resultStats" bit arıyor dosyayı ayrıştırmak istiyorum.

Sen $html bir değişken depolanan çıkan html ve sonra gibi bir şey söylemek istiyorum

$arr = explode('<p id="resultStats"'>, $html);
$bottom = $arr[1];
$middle = explode('</p>', $bottom);

Bu denenmemiş ve çok kaba bir örnek olduğunu unutmayın. Eğer özel bir çözümleyici ile html ayrıştırma veya normal ifadelerle hattıyla daha iyi olurdu.

Stackoverflow.com var about 830K - site:yourdomainhere.com sonuçlarının sayısını