Skip to content

Latest commit

 

History

History
77 lines (58 loc) · 2.38 KB

Google Maps.md

File metadata and controls

77 lines (58 loc) · 2.38 KB

Google Maps Scraper With PHP

The library provides real-time access to the places from Google Maps via Outscraper API. It allows easy scraping of businesses information from Google Maps.

screencast

Installation

Composer

You can install the bindings via Composer. Run the following command:

composer require outscraper/outscraper

To use the bindings, use Composer's autoload:

require_once('vendor/autoload.php');

Manual Installation

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.

require_once('/path/to/outscraper-php/init.php');

Link to the PHP package page

Initialization

$client = new OutscraperClient("SECRET_API_KEY");

Link to the profile page to create the API key

Usage

# Search for businesses in specific locations:
$results = $client->google_maps_search(['restaurants brooklyn usa'], limit: 20, language: 'en', region: 'us');

# Get data of the specific place by id
$results = $client.google_maps_search(['ChIJrc9T9fpYwokRdvjYRHT8nI4'], language: 'en');

# Scrap Places by Two Queries
$results = $client->google_maps_search(
    ['restaurants brooklyn usa', 'bars brooklyn usa'],
    limit: 50, # limit of palces per each query
    language: 'en',
    region: 'US',
);

foreach ($results as &$query_places) {
    foreach ($query_places as &$place) {
        print($place['query']);
        print($place['name']);
        print($place['phone']);
        print($place['site']);
    }
};

# Scrap Places by Place Ids
$results = $client->google_maps_search(
    ["ChIJ8ccnM7dbwokRy-pTMsdgvS4", "ChIJN5X_gWdZwokRck9rk2guJ1M", "ChIJxWLy8DlawokR1jvfXUPSTUE"],
    limit: 1, # limit of palces per each query
);

foreach ($results as &$query_places) {
    foreach ($query_places as &$place) {
        print($place['query']);
        print($place['place_id']);
    }
};