목차

Google Maps Scraping in Pure PHP

Good knowledge of coding, browser emulation, proxies, and reCAPTCHA solver is required for scraping Google Maps. Additionally, it would help if you were prepared to deal with any modifications Google may make to its dynamic content.

Initially, you will need to emulate the behavior of a real user via browser emulation. Therefore, using 셀레늄 or other browser emulators could be an efficient option.

You must use 프록시 if you wish to protect your office/home IP address, thus, you can request websites from the IPs of other users.

Even with this array of tools, Google may present you with reCAPTCHA and bind it to some of your IPs if you have sufficient usage. You can add a  리캡차 솔버 if you do not want to alter IPs whenever you encounter a reCAPTCHA.

Besides this, be prepared for the possibility that Google may alter its content. It can be achieved by conducting daily tests.

Even though implementing the scraper may take some time, it can be built and maintained. To learn how to scrape Google Maps using Python and Selenium, visit this step-by-step tutorial: 파이썬과 셀레늄으로 Google 지도를 스크랩하는 방법.

Google Maps Scraping With Outscraper PHP Package

A more robust way of scraping Google Maps will be using the Outscraper PHP library. 에 대한 편리한 액세스를 제공합니다. Outscraper API from applications written in the PHP language which allows you to use Outscraper의 서비스 를 코드에서 제거합니다.

먼저 다음을 설치하여 시작할 수 있습니다. 패키지 에서 계정을 만들고 아웃 스크레이퍼.

설치

Composer

Install the Outscraper SDK 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');
				
			

초기화

클래스를 가져오고 비밀 API 키를 추가하여 Outscraper 클라이언트를 초기화합니다. API 키는 다음에서 생성할 수 있습니다. 프로필 페이지.

				
					$client = new OutscraperClient("SECRET_API_KEY");
				
			

사용 예

다음은 검색어를 사용하여 Google 지도에서 장소를 스크랩하는 방법의 예입니다:

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

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

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

장소 ID를 사용하여 데이터를 추출할 수도 있습니다:

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

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

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

지금 Outscraper SDK 체험하기

The Outscraper SDK is available for you to easily do Google Maps Scraping with PHP. You can try it right now with a Free Tier.

자주하는 질문

가장 자주 묻는 질문과 답변

Outscraper SDK를 사용하여 Google 지도 결과를 스크랩할 수 있습니다. 검색어, 언어 및 기타 매개변수를 지정하고 요청을 전송하세요.

composer require outscraper/outscraper
require_once('vendor/autoload.php');
$client = new OutscraperClient("SECRET_API_KEY");
# Search for businesses in specific locations:
$results = $client->google_maps_search_v2(['restaurants brooklyn usa'], limit: 20, language: 'en', region: 'us');
# Scrap Places by Two Queries
$results = $client->google_maps_search_v2(
['restaurants brooklyn usa', 'bars brooklyn usa'],
limit: 50, # limit of palces per each query
language: 'en',
region: 'US',
);
# Iterate over the results
foreach ($results as &$query_places) {
foreach ($query_places as &$place) {
print($place['query']);
print($place['name']);
print($place['phone']);
print($place['site']);
}
};

Google 지도를 스크랩하려면 코딩, 브라우저 에뮬레이션, 프록시, 프록시에 대한 지식이 필요합니다. 리캡차 솔버. 또한 Google이 동적 콘텐츠에 적용할 수 있는 변경 사항도 처리할 준비가 되어 있어야 합니다.

Google 지도는 스크래핑을 허용하지 않습니다. 하지만 공공 데이터를 스크랩하고 추출하는 행위는 미국 수정헌법 제1조에 의해 보호됩니다.

카테고리: API

유누스

마케팅 담당자, 콘텐츠 작성자, 고객 경험 개발자 페이스북 | 링크드인 | 트위터

0 댓글

답글 남기기

아바타 자리 표시자