GitHunt
HU

The PHP SERP Spider - A search engine scraper

SERPS

Search Engine Result Page Scrapper

Build Status
Test Coverage
Gitter

This is a work in progress.

Install

Install it using composer: composer require serps/serps

The base package does not include an http client.
We advice you to use our curl client: composer require serps/http-client-curl

Usage

The following usage is only a short example, you can check the full documentation.

    use Serps\SearchEngine\Google\GoogleClient;
    use Serps\HttpClient\CurlClient;
    use Serps\SearchEngine\Google\GoogleUrl;
    use Serps\Exception\CaptchaException;
    use Serps\Exception\RequestErrorException;
    
    $googleClient = new GoogleClient(new CurlClient());
    
    $googleUrl = new GoogleUrl('google.fr');
    $googleUrl->setSearchTerm('simpsons');
    
    try {
        $googleSerp = $googleClient->query($googleUrl);
        $results = $googleSerp->getNaturalResults();
        
        foreach($results as $result){
            $resultType = $result->getType();
            $resultPosition = $result->getPosition();
            // an array of data depending on the result type
            $resultData = $result->getData(); 
        } 
    } catch (CaptchaException $e) {
        // Captcha must be solved to continue with this ip
    } catch (RequestErrorException $e) {
        // Non-captcha error (not found, network error...)
    }

Languages

PHP98.6%Shell1.4%

Contributors

Other
Created May 21, 2016
Updated May 21, 2016
hughsaffar/core | GitHunt