Skip to content

최고의 Google Maps Scraper API로 리뷰, 평점, 사진 등 Google Maps データ를 추출합니다. 지금 무료 체험을 시작하세요!

Notifications You must be signed in to change notification settings

bright-kr/Google-Maps-Scraper

Repository files navigation

Google Maps Scraper

Table of Contents

Free Google Maps Scraper

이 무료 스크레이퍼를 사용하여 Google Maps에서 비즈니스 리뷰를 추출합니다. 몇 단계만으로 리뷰어 정보, 평점, 리뷰 텍스트, 사진 등 다양한 세부 정보를 가져올 수 있습니다.

Setup and Installation

시작하기 전에 다음 사전 요구 사항이 설치되어 있는지 확인합니다:

  • Python 3.9+
  • Playwright(브라우저 자동화용)

다음 단계에 따라 모든 것을 설정합니다:

  1. 리포지토리를 로컬 머신에 클론합니다

  2. free-scraper 디렉터리로 이동합니다

  3. 필요한 의존성을 설치합니다:

    pip install playwright
    playwright install

How to Use the Scraper

스크레이퍼 사용 방법을 단계별로 살펴보겠습니다:

  1. main.py를 열고 대상 Google Maps URL을 추가합니다:

    urls = [
            "https://www.google.com/maps/place/Joe's+Pizza+Broadway/@40.7546835,-73.989604,17z/data=!3m1!5s0x89c259ab3e91ed73:0x4074c4cfa25e210b!4m8!3m7!1s0x89c259ab3c1ef289:0x3b67a41175949f55!8m2!3d40.7546795!4d-73.9870291!9m1!1b1!16s%2Fg%2F11bw4ws2mt?entry=ttu",
            "https://www.google.com/maps/place/Googleplex/@37.4220583,-122.0878991,17z/data=!4m8!3m7!1s0x808fba02425dad8f:0x6c296c66619367e0!8m2!3d37.4220541!4d-122.0853242!9m1!1b1!16zL20vMDNiYnkx?hl=en&entry=ttu",
            # Add as many URLs as you need
        ]
  2. 다음을 사용하여 스크립트를 실행합니다:

    python main.py

Output

스크레이퍼는 결과를 free_scraper_output.json에 저장하며, 포함 내용은 다음과 같습니다:

{
    "reviewer_name": "Jacqueline",
    "reviewer_link": "https://www.google.com/maps/contrib/108281841745817069467/reviews?hl=en-GB",
    "reviewer_image": "https://lh3.googleusercontent.com/a-/ALV-UjUzl62rTNZOxsKGxvlnjM3leUg7DZostYzDJvG_8DUSNEtC7p-X=w36-h36-p-rp-mo-ba4-br100",
    "rating": 5,
    "date": "a week ago",
    "text": "Went for lunch on a Tuesday at around 12:45pm. As usual, there was a line, but it moved really quickly and I was able to get my pizza 10 minutes later. Don't let the line deter you from trying Joe's! The pizza is great as always and the staff are nice. Never disappointed. I tried the caprese pizza and it was great!\n\nThere are a lot of people inside and outside so it can get hectic, but turnover for seats is quite quick and I got a seat on the bench outside almost right away.",
    "photos": [
        "https://lh5.googleusercontent.com/p/AF1QipMChGwUdQgWF9NAqdvss36KeuBZw_DAiuZy5yJj=w300-h225-p-k-no",
        "https://lh5.googleusercontent.com/p/AF1QipNvachPq2HyJU0_3hs0DsRDRChaHZrQDDKOc3hz=w300-h225-p-k-no"
    ],
    "likes_count": "1"
}

각 리뷰 항목에는 다음이 포함됩니다:

  • 리뷰어 세부 정보: 이름, 프로필 링크, 아바타 이미지
  • 리뷰 내용: 별점, 게시 날짜, 전체 리뷰 텍스트
  • 미디어: 첨부된 사진이 있는 경우 해당 URL
  • 참여도: 리뷰가 받은 좋아요 수

Common Scraping Challenges

Google Maps에서 데이터를 스크레이핑하는 것은 상당히 어려울 수 있습니다. 다음은 흔히 마주칠 수 있는 문제입니다:

  1. 동적 콘텐츠 로딩: Google Maps는 사용자가 스크롤할 때 XHR/API 호출을 통해 리뷰를 가져오는 동적 로딩 메커니즘을 사용합니다. 이러한 동적 리クエスト를 적절히 처리하고 콘텐츠가 로드될 때까지 기다리지 않으면, 스크레이퍼가 부분 데이터만 수집할 수 있습니다.
  2. DOM 구조 변경: Google은 DOM 구조, 클래스 이름, 데이터 속성을 자주 업데이트합니다. 이에 따라 구조적 변경에 적응하기 위해 스크레이핑 로직을 정기적으로 유지보수해야 합니다.
  3. 속도 제한 및 탐지: Google Maps를 스크레이핑하면 안티봇 방어가 트리거될 수 있으며, 그 결과 속도 제한 또는 IP 차단이 발생할 수 있습니다.

Solution: Bright Data Google Maps Scraper API

신뢰할 수 있는 대규모 데이터 추출이 필요하다면 Bright Data Google Maps Scraper API를 사용합니다. 더 효과적인 이유는 다음과 같습니다:

  • 프록시 관리가 필요하지 않습니다
  • 전 세계 어느 위치에서든 스크레이핑할 수 있습니다
  • 195개 국가에 걸친 7,200만+ 개의 실제 IP에 접근할 수 있습니다
  • 다양한 데이터 전달 옵션(S3, Cloud Storage 등)
  • GDPR 및 CCPA 준수
  • 24/7 기술 지원

또한 테스트를 위해 무료 API 호출 20회가 제공됩니다.

Using Google Maps Scraper API

URL만 제공하면 상세한 Google Maps 리뷰를 수집할 수 있습니다.

bright-data-web-scraper-api-google-maps-reviews

Google Maps Scraper API 설정에 대한 자세한 가이드는 Step-by-Step Setup Guide를 확인합니다.

주요 입력 매개변수:

Parameter Type Description Required
url string Google Maps 비즈니스 URL Yes
days_limit number 리뷰를 가져올 기간(일) No

샘플 출력 데이터:

{
    "url": "https://www.google.com/maps/place/Apple+Apple+Park+Visitor+Center/@37.3327772,-122.0079593,17z/data=!4m18!1m9!3m8!1s0x808fb5c5d7e7a3d1:0x1741de234d732f80!2sApple+Apple+Park+Visitor+Center!8m2!3d37.332773!4d-122.0053844!9m1!1b1!16s%2Fg%2F11rjtz4vtg!3m7!1s0x808fb5c5d7e7a3d1:0x1741de234d732f80!8m2!3d37.332773!4d-122.0053844!9m1!1b1!16s%2Fg%2F11rjtz4vtg?entry=ttu",
    "place_id": "ChIJ0aPn18W1j4ARgC9zTSPeQRc",
    "place_name": "Apple Apple Park Visitor Center",
    "country": "US",
    "address": "10600 N Tantau Ave, Cupertino, CA 95014",
    "review_id": "ChdDSUhNMG9nS0VJQ0FnSUMzcDdqMHJRRRAB",
    "reviewer_name": "Krzysztof Wojtczak",
    "reviews_by_reviewer": 32,
    "photos_by_reviewer": "12",
    "reviewer_url": "https://www.google.com/maps/contrib/110797405132582450368/reviews?hl=en",
    "local_guide": true,
    "review_rating": 5,
    "review": "Fajnie można spędzić czas, czilując na tarasie z kawką 🤙",
    "review_date": "2024-11-09T22:18:01.713Z",
    "number_of_likes": 0,
    "response_of_owner": null,
    "response_date": null,
    "photos": [
      "https://lh5.googleusercontent.com/p/AF1QipOtSDFfVpLL5GopXJzoFbTapha0G91nmEx5aSus",
      "https://lh5.googleusercontent.com/p/AF1QipPcr5_TU6MWhAu1_K54DbxywZ4O88Q_qT7NSnhv",
      "https://lh5.googleusercontent.com/p/AF1QipNLM5jHD0iDozGHsax9ydGAWUI_pn_fujQ3Q4Wr",
      "https://lh5.googleusercontent.com/p/AF1QipPcKPwXyHDawuClpTpfV3zE7vMFO0UabmdjX9IG"
    ],
    "timestamp": "2024-11-10T07:37:58.326Z",
    "input": {
      "url": "https://www.google.com/maps/place/Apple+Apple+Park+Visitor+Center/@37.3327772,-122.0079593,17z/data=!4m18!1m9!3m8!1s0x808fb5c5d7e7a3d1:0x1741de234d732f80!2sApple+Apple+Park+Visitor+Center!8m2!3d37.332773!4d-122.0053844!9m1!1b1!16s%2Fg%2F11rjtz4vtg!3m7!1s0x808fb5c5d7e7a3d1:0x1741de234d732f80!8m2!3d37.332773!4d-122.0053844!9m1!1b1!16s%2Fg%2F11rjtz4vtg?entry=ttu",
      "days_limit": 30
    }
  }

전체 출력은 이 샘플 JSON 파일을 다운로드하여 확인할 수 있습니다.

Code Example:

다음은 Google Maps 리뷰를 수집하고 결과를 JSON 파일에 저장하는 Python 스크립트입니다:

import requests
import json
import time


class BrightData:
    def __init__(self, api_token):
        self.api_token = api_token
        self.headers = {
            "Authorization": f"Bearer {api_token}",
            "Content-Type": "application/json",
        }

    def collect_reviews(self, urls_data):
        """
        Collect Google Maps reviews using BrightData API
        """
        # 1. Trigger data collection
        print("Starting data collection...")
        trigger_response = self._trigger_collection(urls_data)
        snapshot_id = trigger_response.get("snapshot_id")
        print(f"Snapshot ID: {snapshot_id}")

        # 2. Wait for data to be ready
        print("Waiting for data...")
        while True:
            status = self._check_status(snapshot_id)
            print(f"Status: {status}")

            if status == "ready":
                # Check if data is actually available
                data = self._get_data(snapshot_id)
                if data and len(data) > 0:
                    break
            time.sleep(10)  # Wait 10 seconds before next check

        # 3. Get and save the data
        print("Saving data...")
        filename = f"api_scraper_output.json"
        with open(filename, "w", encoding="utf-8") as f:
            json.dump(data, f, indent=2, ensure_ascii=False)
        print(f"✓ Data saved to {filename}")
        print(f"✓ Collected {len(data)} reviews")
        return data

    def _trigger_collection(self, urls_data):
        """Trigger data collection"""
        response = requests.post(
            "https://api.brightdata.com/datasets/v3/trigger",
            headers=self.headers,
            params={"dataset_id": "gd_luzfs1dn2oa0teb81",
                    "include_errors": "true"},
            json=urls_data,
        )
        return response.json()

    def _check_status(self, snapshot_id):
        """Check collection status"""
        response = requests.get(
            f"https://api.brightdata.com/datasets/v3/progress/{snapshot_id}",
            headers=self.headers,
        )
        return response.json().get("status")

    def _get_data(self, snapshot_id):
        """Get collected data"""
        response = requests.get(
            f"https://api.brightdata.com/datasets/v3/snapshot/{snapshot_id}",
            headers=self.headers,
            params={"format": "json"},
        )
        return response.json()


if __name__ == "__main__":
    # Initialize with your API token
    brightdata = BrightData("<YOUR_API_TOKEN>")

    # Define URLs to collect reviews from
    urls_to_collect = [
        {
            "url": "https://www.google.com/maps/place/Apple+Apple+Park+Visitor+Center/@37.3327772,-122.0079593,17z/data=!4m18!1m9!3m8!1s0x808fb5c5d7e7a3d1:0x1741de234d732f80!2sApple+Apple+Park+Visitor+Center!8m2!3d37.332773!4d-122.0053844!9m1!1b1!16s%2Fg%2F11rjtz4vtg!3m7!1s0x808fb5c5d7e7a3d1:0x1741de234d732f80!8m2!3d37.332773!4d-122.0053844!9m1!1b1!16s%2Fg%2F11rjtz4vtg?entry=ttu",
            "days_limit": 30,
        },
        {
            "url": "https://www.google.com/maps/place/Joe's+Pizza+Broadway/@40.7546835,-73.989604,17z/data=!3m1!5s0x89c259ab3e91ed73:0x4074c4cfa25e210b!4m8!3m7!1s0x89c259ab3c1ef289:0x3b67a41175949f55!8m2!3d40.7546795!4d-73.9870291!9m1!1b1!16s%2Fg%2F11bw4ws2mt?entry=ttu",
            "days_limit": 25,
        },
    ]

    # Collect reviews
    reviews = brightdata.collect_reviews(urls_to_collect)

코드 동작 방식:

  1. API Token 필요: 먼저 API token이 필요합니다. 아직 없다면 Google Maps Scraper API setup guide를 따릅니다.
  2. 데이터 수집 시작: 코드에 API token을 전달하면, 지정한 매개변수로 데이터 수집을 시작합니다. 이때 리クエ스트를 추적하는 데 사용할 snapshot_id가 반환됩니다.
  3. 결과 대기: 데이터 수집은 완료까지 몇 분이 걸립니다. 이 동안 코드는 snapshot_id 상태를 지속적으로 확인합니다:
    • 상태 "running" = 데이터가 아직 수집 중입니다
    • 상태 "ready" = 데이터 수집이 완료되었고 JSON 파일에 저장되었습니다
  4. 추가 매개변수: _trigger_collection 함수에 더 많은 매개변수를 추가하여 데이터 수집을 사용자 지정할 수 있습니다. 사용 가능한 매개변수와 다양한 데이터 전달 방법을 알아보려면 다음 섹션을 확인합니다.

Customizing Data Collection with API Parameters

다음 API 매개변수를 사용하여 데이터 수집을 사용자 지정합니다:

Parameter Type Description Example
limit integer 각 입력에 대해 반환되는 결과 수를 제한합니다. limit=10
include_errors boolean 문제 해결을 위해 출력에 오류 보고서를 포함합니다. include_errors=true
notify url 수집이 완료되면 알림이 전송되는 URL입니다. notify=https://notify-me.com/
format enum 데이터 전달 형식입니다. 지원 형식: JSON, NDJSON, JSONL, CSV. format=json

💡추가 전달 방법: webhook 또는 API를 통해 데이터를 전달하도록 선택할 수 있습니다.

Releases

No releases published

Packages

No packages published

Languages