1. Go to this page and download the library: Download athlon1600/serpscraper 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/ */
athlon1600 / serpscraper example snippets
use SerpScraper\Engine\GoogleSearch;
$page = 1;
$google = new GoogleSearch();
// all available preferences for Google
$google->setPreference('results_per_page', 100);
//$google->setPreference('google_domain', 'google.lt');
//$google->setPreference('date_range', 'hour');
$results = array();
do {
$response = $google->search("how to scrape google", $page);
// error field must be empty otherwise query failed
if(empty($response->error)){
$results = array_merge($results, $response->results);
$page++;
} else if($response->error == 'captcha'){
// read below
break;
}
} while ($response->has_next_page);
use SerpScraper\Engine\GoogleSearch;
use SerpScraper\GoogleCaptchaSolver;
$google = new GoogleSearch();
$browser = $google->getBrowser();
$browser->setProxy('PROXY:IP');
$solver = new GoogleCaptchaSolver($browser);
while(true){
$response = $google->search('famous people born in ' . mt_rand(1500, 2020));
if ($response->error == 'captcha') {
echo "Captcha detected!" . PHP_EOL;
$temp = $solver->solveUsingTwoCaptcha($response, '2CAPTCHA_API_KEY', 90);
if ($temp->status == 200) {
echo "Captcha solved successfully!" . PHP_EOL;
} else {
echo 'Solving captcha has failed...' . PHP_EOL;
}
} else {
echo "OK. ";
}
sleep(2);
}