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.
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');
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');
$client = new OutscraperClient("SECRET_API_KEY");
Link to the profile page to create the API key
# 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']);
}
};