PHP code example of rubtsovav / yandex-wordstat-parser
1. Go to this page and download the library: Download rubtsovav/yandex-wordstat-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rubtsovav / yandex-wordstat-parser example snippets
use RubtsovAV\YandexWordstatParser\Parser;
use RubtsovAV\YandexWordstatParser\Query;
use RubtsovAV\YandexWordstatParser\YandexUser;
use RubtsovAV\YandexWordstatParser\CaptchaInterface;
use RubtsovAV\YandexWordstatParser\Browser\ReactPhantomJs;
use RubtsovAV\YandexWordstatParser\Proxy\Http as HttpProxy;
$yandexUser = new YandexUser('test12345678902017', 'test1234567890', __DIR__ . '/storage');
$proxy = new HttpProxy('1.179.198.17', 8080);
$browser = new ReactPhantomJs();
$browser->setProxy($proxy); // optional
$browser->setTimeout(60); // in seconds (120 by default)
$browser->setCaptchaSolver(function($captcha) {
$image = file_get_contents($captcha->getImageUri());
file_put_contents(__DIR__ . '/captcha.jpg', $image);
file_put_contents(__DIR__ . '/captchaAnswer.txt', '');
echo "The captcha image was save to captcha.jpg. Write the answer in captchaAnswer.txt\n";
$answer = '';
while (!$answer) {
$answer = file_get_contents(__DIR__ . '/captchaAnswer.txt');
$answer = trim($answer);
sleep(1);
}
echo "The captcha answer is '$answer'\n";
$captcha->setAnswer($answer);
return true;
});
$parser = new Parser($browser, $yandexUser);
$query = new Query('купить диван');
$result = $parser->query($query);
print_r($result->toArray());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.