목차

Google Maps Scraping In Pure Python​

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

First of all, you will need to mimic the real user’s behavior by using browser emulation. Using 셀레늄 or other browser emulators might be a good solution.

Secondly, if you want to keep your office/home IP safe, you will need to use 프록시. So you can request websites from other people’s IPs.

Even with that set of tools, once you have some good usage, Google might show you reCAPTCHA and bind it to some of your IPs. If you do not want to change IPs every time you see a reCAPTCHA, you can add a 리캡차 솔버.

Additionally, be prepared for situations when Google might change its content. You can do it by running daily tests.

Although it might take some time to implement the scraper, it can be built and maintained. Check out this step-by-step tutorial on how to scrape Google Maps using Python and Selenium to learn more: How to Scrape Google Maps with Python and Selenium.

Google Maps Scraping With Outscraper Python Package

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

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

Google Maps Scraping in Python

설치

Install the Outscraper SDK by running the following command (Python 3+ is required):

				
					pip install outscraper
				
			

초기화

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

				
					from outscraper import ApiClient

client = ApiClient(api_key='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
for query_places in results:
    for place in query_places:
        print('query:', place['query'])
        print('name:', place['name'])
        print('phone:', place['phone'])
        print('website:', 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
for query_places in results:
    for place in query_places:
        print('name:', place['name'])
        print('place_id:', place['place_id'])
				
			

지금 Outscraper SDK 체험하기

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

자주하는 질문

가장 자주 묻는 질문과 답변

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

pip install outscraper
from 아웃 스크레이퍼 import ApiClient
client = ApiClient(api_key='SECRET_API_KEY')
# Search for businesses in specific locations:
results = client.google_maps_search('restaurants brooklyn usa', limit=20, language='en')

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

# Search with many queries (batching)
results = client.google_maps_search([
    'restaurants brooklyn usa',
    'bars brooklyn usa',
], language='en')

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

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

카테고리: API

유누스

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

0 댓글

답글 남기기

아바타 자리 표시자