Skip to content

Commit

Permalink
add new params
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-stack committed Jul 4, 2022
1 parent bb768c1 commit 7ccca04
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions google-maps-scraper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @link https://github.com/outscraper/google-maps-scraper-php
*/
class ApiClient {
public $version = "1.2.1";
public $version = "1.3.0";
private $api_url = "https://api.app.outscraper.com";
private $api_headers;
private $max_ttl = 60 * 60;
Expand Down Expand Up @@ -141,12 +141,13 @@ public function google_maps_search(
* @param bool $extract_contacts Parameter specifies whether the bot will scrape additional data (emails, social links, site keywords…) from companies’ websites. It increases the time of the extraction.
* @param string $coordinates Parameter defines the coordinates to use along with the query. Example: "@41.3954381,2.1628662,15.1z".
* @param bool $drop_duplicates Parameter specifies whether the bot will drop the same organizations from different queries. Using the parameter combines results from each query inside one big array.
* @param int $skip Skip first N places, where N should be multiple to 20 (e.g. 0, 20, 40). It's commonly used in pagination.
*
* @return array request/task result
*/
public function google_maps_search_v2(
string|array $query, string $language = "en", string $region = NULL, int $organizations_per_query_limit = 400,
string $coordinates = NULL, bool $drop_duplicates = FALSE
string $coordinates = NULL, bool $drop_duplicates = FALSE, int $skip = 0
) : array {
$params = http_build_query(array(
"query" => $this->to_array($query),
Expand All @@ -155,6 +156,7 @@ public function google_maps_search_v2(
"organizationsPerQueryLimit" => $organizations_per_query_limit,
"coordinates" => $coordinates,
"dropDuplicates" => $drop_duplicates,
"skipPlaces" => $skip,
"async" => FALSE,
));
$result = $this->make_get_request("maps/search-v2?{$params}");
Expand All @@ -173,13 +175,14 @@ public function google_maps_search_v2(
* @param int $cutoff Parameter specifies the maximum timestamp value for reviews. Using the cutoff parameter overwrites sort parameter to newest.
* @param int $cutoffRating Parameter specifies the maximum (for lowest_rating sorting) or minimum (for highest_rating sorting) rating for reviews. Using the cutoffRating requires sorting to be set to "lowest_rating" or "highest_rating".
* @param string $sort Parameter specifies one of the sorting types. Available values: "most_relevant", "newest", "highest_rating", "lowest_rating".
* @param string $reviews_query Parameter specifies the query to search among the reviews (e.g. wow, amazing, horrible place).
*
* @return array request/task result
*/
public function google_maps_reviews(
string|array $query, string $language = "en", string $region = NULL, int $organizations_per_query_limit = 1,
int $limit = 100, string $coordinates = NULL, int $cutoff = NULL, int $cutoff_rating = NULL,
string $sort = "most_relevant"
string $sort = "most_relevant", string $reviews_query = NULL
) : array {
$params = http_build_query(array(
"query" => $this->to_array($query),
Expand All @@ -190,12 +193,50 @@ public function google_maps_reviews(
"coordinates" => $coordinates,
"cutoff" => $cutoff,
"cutoffRating" => $cutoff_rating,
"reviewsQuery" => $reviews_query,
"sort" => $sort
));
$result = $this->make_get_request("maps/reviews-v2?{$params}");
return $this->wait_request_archive($result["id"]);
}

/**
* Get reviews from Google Maps (speed optimized)
*
* @param string|array $query Parameter defines the query or queries you want to search on Google Maps. Using an array allows multiple queries to be sent in one request and save on network latency time.
* @param string $language Parameter specifies the language to use for Google. Available values: "en", "de", "es", "es-419", "fr", "hr", "it", "nl", "pl", "pt-BR", "pt-PT", "vi", "tr", "ru", "ar", "th", "ko", "zh-CN", "zh-TW", "ja", "ach", "af", "ak", "ig", "az", "ban", "ceb", "xx-bork", "bs", "br", "ca", "cs", "sn", "co", "cy", "da", "yo", "et", "xx-elmer", "eo", "eu", "ee", "tl", "fil", "fo", "fy", "gaa", "ga", "gd", "gl", "gn", "xx-hacker", "ht", "ha", "haw", "bem", "rn", "id", "ia", "xh", "zu", "is", "jw", "rw", "sw", "tlh", "kg", "mfe", "kri", "la", "lv", "to", "lt", "ln", "loz", "lua", "lg", "hu", "mg", "mt", "mi", "ms", "pcm", "no", "nso", "ny", "nn", "uz", "oc", "om", "xx-pirate", "ro", "rm", "qu", "nyn", "crs", "sq", "sk", "sl", "so", "st", "sr-ME", "sr-Latn", "su", "fi", "sv", "tn", "tum", "tk", "tw", "wo", "el", "be", "bg", "ky", "kk", "mk", "mn", "sr", "tt", "tg", "uk", "ka", "hy", "yi", "iw", "ug", "ur", "ps", "sd", "fa", "ckb", "ti", "am", "ne", "mr", "hi", "bn", "pa", "gu", "or", "ta", "te", "kn", "ml", "si", "lo", "my", "km", "chr".
* @param string $region Parameter specifies the region to use for Google. Available values: "AF", "AL", "DZ", "AS", "AD", "AO", "AI", "AG", "AR", "AM", "AU", "AT", "AZ", "BS", "BH", "BD", "BY", "BE", "BZ", "BJ", "BT", "BO", "BA", "BW", "BR", "VG", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "CF", "TD", "CL", "CN", "CO", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "EE", "ET", "FJ", "FI", "FR", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GT", "GG", "GY", "HT", "HN", "HK", "HU", "IS", "IN", "ID", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KW", "KG", "LA", "LV", "LB", "LS", "LY", "LI", "LT", "LU", "MG", "MW", "MY", "MV", "ML", "MT", "MU", "MX", "FM", "MD", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NZ", "NI", "NE", "NG", "NU", "MK", "NO", "OM", "PK", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RO", "RU", "RW", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "KR", "ES", "LK", "SH", "VC", "SR", "SE", "CH", "TW", "TJ", "TZ", "TH", "TL", "TG", "TO", "TT", "TN", "TR", "TM", "VI", "UG", "UA", "AE", "GB", "US", "UY", "UZ", "VU", "VE", "VN", "ZM", "ZW".
* @param int $organizations_per_query_limit Parameter specifies the limit of organizations to take from one query search. Usually, there are no more than 400 organizations per one query search on Google Maps. Use more precise categories (asian restaurant, italian restaurant, etc.) to overcome this limitation.
* @param int $limit Parameter specifies the limit of reviews to extract from one organization.
* @param string $coordinates Parameter defines the coordinates to use along with the query. Example: "@41.3954381,2.1628662,15.1z".
* @param int $cutoff Parameter specifies the maximum timestamp value for reviews. Using the cutoff parameter overwrites sort parameter to newest.
* @param int $cutoffRating Parameter specifies the maximum (for lowest_rating sorting) or minimum (for highest_rating sorting) rating for reviews. Using the cutoffRating requires sorting to be set to "lowest_rating" or "highest_rating".
* @param string $sort Parameter specifies one of the sorting types. Available values: "most_relevant", "newest", "highest_rating", "lowest_rating".
* @param string $reviews_query Parameter specifies the query to search among the reviews (e.g. wow, amazing, horrible place).
*
* @return array request/task result
*/
public function google_maps_reviews_v3(
string|array $query, string $language = "en", string $region = NULL, int $organizations_per_query_limit = 1,
int $limit = 100, string $coordinates = NULL, int $cutoff = NULL, int $cutoff_rating = NULL,
string $sort = "most_relevant", string $reviews_query = NULL
) : array {
$params = http_build_query(array(
"query" => $this->to_array($query),
"language" => $language,
"region" => $region,
"organizationsPerQueryLimit" => $organizations_per_query_limit,
"reviewsPerOrganizationLimit" => $limit,
"coordinates" => $coordinates,
"cutoff" => $cutoff,
"cutoffRating" => $cutoff_rating,
"reviewsQuery" => $reviews_query,
"sort" => $sort
));
$result = $this->make_get_request("maps/reviews-v3?{$params}");
return $this->wait_request_archive($result["id"]);
}

/**
* Return email addresses, social links and phones from domains in seconds.
*
Expand Down

0 comments on commit 7ccca04

Please sign in to comment.