A
A
Alejandro Dominguez2014-07-19 17:00:01
PHP
Alejandro Dominguez, 2014-07-19 17:00:01

How to find pages in the index through Yandex.XML?

Hello everyone, I'm doing an analysis of SEO indicators on my site , everything works out, except for one thing - I just can't find out the number of indexed pages in Yandex search. There are a lot of instructions on the Internet, but for some reason none of them work for me. At the moment I'm trying to get the treasured number from Yandex xml using this code:

$postdata = '<?xml version="1.0" encoding="UTF-8"?><request><query>site:sanek.co</query><sortby></sortby><maxpassages>1</maxpassages><page>0</page><groupings><groupby attr="d" mode="deep" groups-on-page="10" docs-in-group="3" /></groupings></request>';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://xmlsearch.yandex.ru/xmlsearch?user=adryzzzy&key=МОЙКЛЮЧ");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, "");
$data = curl_exec($ch);
curl_close($ch);

preg_match('!<found priority="phrase">[0-9]+</found>\s*!s', $data, $posdata);
echo $posdata[0];

In response, I get an empty string. Poke, please, with your finger, what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Belov, 2014-07-19
@IPRIT

Use SimpleXML in PHP.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question