The PHP SERP Spider - A search engine scraper
PHP Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
build
src
test
.editorconfig
.gitattributes
.gitignore
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
LICENSE
README.md
composer.json
phpcs.xml
phpunit.dist.xml

README.md

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...)
    }