Вот тут http://xml.yandex.ru/games/site-search-php.html.
1 | $found_all = $xmldoc->response->found; |
1 | $found_all=$xmldoc->response->results->grouping->found; |
1 | $found_all = $xmldoc->response->results->grouping->{'found-docs'}; |
http://yandex.ru/yandsearch?text=%D1%8E%D0%BC%D0%BE%D1%80+site%3Alib.ru&lr=19
Наглядно видно разницу.(сейчас уже нет, ибо починили, так что теперь это не актуально)
Скрипт запускаю кстати с линукса. Специально под это дело (ну и не только под это, конечно) знакомый купил хостинг в Украине. И домен там же зарегистрировал.
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 | <?php function check_site_indexing($host, $XML_KEY) { $ehost = htmlspecialchars($host); $search = htmlspecialchars("site:$ehost"); // xml request $doc = <<<DOC <?xml version='1.0' encoding='utf-8'?> <request> <query>$search</query> <groupings> <groupby attr="" mode="flat" groups-on-page="10" docs-in-group="1" /> </groupings> <page>0</page> </request> DOC; // init context for post request $context = stream_context_create(array( 'http' => array( 'method'=>"POST", 'header'=>"Content-type: application/xml\r\n" . "Content-length: " . strlen($doc), 'content'=>$doc ) )); // do xml request $response = file_get_contents($XML_KEY, true, $context); if ($response) { $xmldoc = new SimpleXMLElement($response); $error = $xmldoc->response->error; $found_docs1 = $xmldoc->response->results->grouping->{'found-docs'}[0]; if ($error) { //$ret = "Error: " . $error[0]; $ret=-1; } else { //$ret = "Pages in index: $found_docs1\n<br/>"; $ret = (int)$found_docs1; } } else { //$ret = "Some unknown internal server error. No data returned.\n"; $ret=-2; } return $ret; } ?> |
Leave a Reply
<a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>