PHP Classes

serpStack PHP Google Search API: Perform searches on Google using the serpStack API

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 180 All time: 8,717 This week: 524Up
Version License PHP version Categories
serpstack 1.0.0GNU General Publi...5.6PHP 5, Searching, Web services
Description 

Author

This package can perform searches on Google using the serpStack API.

It can send HTTP requests to the serpStack API Web server passing parameters, so it can perform the searches on Google.

The class can take parameters that set the search query, safe search option, etc..

It can return search results for Web pages, images, videos, news and shopping.

Innovation Award
PHP Programming Innovation award winner
November 2019
Winner
Google is obviously the most popular search engine on the Internet.

Performing searches on Google is usually only allowed to be done by real human users, except when you use an API.

This package provides an API to perform searches on Google. It uses a proxy network to avoid sending many searches from the same IP address on behalf of a user of the API.

Manuel Lemos
Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 59
All time rank: 608 in United States United States
Week rank: 14 Up2 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Example

<?php
/*
example usage
serpStack ver 1.0

You must get an API key from https://weatherstack.com/product
and enter it in the weatherstack.class.php file
*/

//turning off low level notices
error_reporting(E_ALL ^ E_NOTICE);

//instantiate the class
include('serpstack.class.php');
$serp = new serpStack();

//set the end point to use
//serp scraping uses the 'search' endpoint
//we can set it with 'search' or 's' shorthand
$serp->setEndPoint('search');

//set the query parameter
$serp->setParam('query','mcdonalds');

//optionally set to a safe search
$serp->setParam('safe','1');

//get the response
$serp->getResponse();

//check for errors
if( !empty($serp->errorCode) ){
   
//error returned
   
echo $serp->errorCode.': '.$serp->errorText;
}else{
   
//loop through and show specific response data
   
foreach($serp->response->organic_results as $result){
   
?>
<h5><a href="<?php echo $result->url;?>"><?php echo $result->title;?></a></h5>
        <div><?php echo $result->snippet;?></div>
        <hr>
    <?php
   
}
}

//displaying the full response
echo '<pre>';
var_dump($serp->response);
echo
'<pre>';
?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example Usage
Accessible without login Plain text file license.txt Lic. License
Plain text file serpstack.class.php Class Main Class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:180
This week:0
All time:8,717
This week:524Up