-
Notifications
You must be signed in to change notification settings - Fork 13
/
fetch_indexed.php
78 lines (59 loc) · 2.22 KB
/
fetch_indexed.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
require_once('inc/db.php');
require_once('inc/helper.php');
require_once('inc/fetch.php');
$fetchYahooIdx = true;
$fetchGoogleIdx = true;
$fetchBingIdx = true;
$saveToDB = true;
echo 'Start fetch Indexed Pages: '.date("Y-m-d H:i:s").'<br>';
foreach ($accounts as $account) {
echo 'Get stat for: '.$account['url'].' - '.date("Y-m-d H:i:s").'<br>';
$result = array();
if ($fetchYahooIdx) {
//http://siteexplorer.search.yahoo.com/search?p=[siteurl]&fr=sfp&bwm=i
$ch = getCURLResource();
curl_setopt($ch, CURLOPT_URL, "http://siteexplorer.search.yahoo.com/search?p=".$account['url']."&fr=sfp&bwm=i");
$buf2 = curl_exec ($ch);
curl_close($ch);
$tempArr = explode('">Pages (', $buf2);
$tempArr = explode(')<', $tempArr[1]);
$indexedPage = str_replace(',', '', $tempArr[0]);
echo 'Yahoo indexed page: '.$indexedPage.'<br>';
}
$result['yindex'] = $indexedPage;
if ($fetchGoogleIdx) {
//check indexed page google
//http://www.google.com/search?hl=en&lr=&q=site%3A[siteurl]&btnG=Search
$ch = getCURLResource();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/search?hl=en&lr=&q=site%3A".$account['url']."&btnG=Search");
$buf2 = curl_exec ($ch);
curl_close($ch);
$arrTemp = explode('results<nobr>',$buf2);
$arrTemp = explode('>',$arrTemp[0]);
$arrTemp = $arrTemp[sizeof($arrTemp)-1];
$arrTemp = str_replace('About ', '', $arrTemp);
$googleidxpage = str_replace(',', '', $arrTemp);
echo 'Google indexed page: '.$googleidxpage.'<br>';
}
$result['gindex'] = $googleidxpage;
if ($fetchBingIdx) {
//bing index
//http://www.bing.com/search?q=site%3A[siteurl]&go=&form=QBRE
$ch = getCURLResource();
curl_setopt($ch, CURLOPT_URL, "http://www.bing.com/search?q=site%3A".$account['url']."&go&FORM=QBRE");
$buf2 = curl_exec ($ch);
curl_close($ch);
$tempArr = explode('<h1>All Results</h1><span class="sb_count" id="count">',$buf2);
$tempArr = explode(' of ',$tempArr[1]);
$tempArr = explode(' results',$tempArr[1]);
$bingindex = str_replace(',', '', $tempArr[0]);
echo 'Bing indexed page: '.$bingindex.'<br>';
}
$result['bingindex'] = $bingindex;
if ($saveToDB) {
saveIndexStat($account,$result);
}
}
echo 'End fetch Indexed Pages: '.date("Y-m-d H:i:s").'<br>';
?>