Skip to content

crawling search engine results and extracting metadata for a set of keywords for the first 5 pages

Notifications You must be signed in to change notification settings

Moussabkobisy/search-engine-crawler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

PHP search engine crawler

Installation

You can install the package via composer:

composer require mossab/search-engine-crawler

or you can add the package to your composer.json then composer install

  "require": {
        //...
        "mossab/search-engine-crawler": "dev-main"
    }

Usage

first of all you need to add your API key and CX to your .env file

<?php
require __DIR__.'/vendor/autoload.php';
(new \src\configs\Config(__DIR__.'/.env'))->load(); // set your .env path

$myGenerator = new src\SearchEngine();
$myGenerator->setEngine('google.com');
$results =  $myGenerator->search(['flower','horizon']);

you will get an ArrayIterator instance contains these parameters :

- keyword being searched
- ranking (where the result was found on the search engine, the topmost result would be 0 and the last would be 50 (results per page x 5)
- url of the page (as it appears in google search)
- title of the page (as it appears in google search)
- description (as it appears in google search)
- promoted This is a boolean value indicating whether the result is an ad or organic result

you can loop results

foreach ($results as $result){
    echo "title is : ".$result['title']."<br>".
        "ranking is = ".$result['ranking']."<br>".
        "url is : ".$result['url']."<br>".
        "description is :".$result['description']."<br>".
        "keyword is :".$result['keyword']."<br>";
}

search Engines

supported search engine is google.com or google.ae

About

crawling search engine results and extracting metadata for a set of keywords for the first 5 pages

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages