googlemaps-scraper

gaspa93GPL-3.0活跃维护

用 Python 抓取 Google Maps 上商户的评论数据,适合做口碑分析和竞品调研时批量采集评论。

Google Maps reviews scraping

v1.1.0发布于 2023-03-25 00:16 UTC534star +2 / 7 天167fork同步于 2026-11-10 11:58 UTC

怎么上手

由 README 提炼,执行前请确认
conda create --name scraping python=3.9 --file requirements.txt
python scraper.py --N 50
硬件要求按 README 说明

README 未说明显存或 GPU 要求;需要本地安装 ChromeDriver 驱动浏览器运行,监控功能需本地安装 MongoDB。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

从 Google Maps 地点链接抓取最新评论并导出 CSV 的 Python 爬虫

用 Python 抓取 Google Maps 上商户的评论数据,适合做口碑分析和竞品调研时批量采集评论。

核心能力

  • 按 POI 评论页 URL 抓取最新评论并输出 CSV
  • 用 --N 控制抓取条数,默认取最近 100 条
  • 支持按最新、最相关、评分高低排序评论
  • monitor.py 配合 MongoDB 增量抓取并突破条数限制
  • 可切换抓取 POI 元数据而非评论

容易踩的坑

需自行下载与浏览器匹配的 Chromedriver,README 未说明版本对应关系;Python 必须 >= 3.9;URL 必须是从地点评论数入口生成的评论页链接,否则无法抓取;monitor.py 需额外安装并运行 MongoDB。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

2 个版本v1.1.0
  1. v1.1.0最新正式版2023-03-25 · 2023-03-25 00:16 UTC

    Two major improvements:

    1. Place metadata scraping has been updated to obtain more information
    2. Defined a first version of place url search by keywords and coordinates

    What's Changed

    New Contributors

    Full Changelog: https://github.com/gaspa93/googlemaps-scraper/compare/v1.0.0...v1.1.0

  2. v1.0.02022-01-08 · 2022-01-08 13:16 UTC
    查看更新说明

    First version with two major features:

    1. Scrape reviews by URL up to 1200 reviews
    2. Integration with MongoDB to add new reviews incrementally

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Google Maps Scraper

    Scraper of Google Maps reviews. The code allows to extract the most recent reviews starting from the url of a specific Point Of Interest (POI) in Google Maps. An additional extension helps to monitor and incrementally store the reviews in a MongoDB instance.

    Installation

    Follow these steps to use the scraper:

    • Download latest version of Chromedrive from here.

    • Install Python packages from requirements file, either using pip, conda or virtualenv:

        conda create --name scraping python=3.9 --file requirements.txt
      

    Note: Python >= 3.9 is required.

    Basic Usage

    The scraper.py script needs two main parameters as input:

    • --i: input file name, containing a list of urls that point to Google Maps place reviews (default: urls.txt)
    • --o: output file name, which will be created in the data folder (default: output.csv)
    • --N: number of reviews to retrieve, starting from the most recent (default: 100)

    Example:

    python scraper.py --N 50

    generates a csv file containing last 50 reviews of places present in urls.txt

    Additionally, other parameters can be provided:

    • --place: boolean value that allows to scrape POI metadata instead of reviews (default: false)
    • --debug: boolean value that allows to run the browser using the graphical interface (default: false)
    • --source: boolean value that allows to store source URL as additional field in CSV (default: false)
    • --sort_by: string value among most_relevant, newest, highest_rating or lowest_rating (default: newest), developed by @quaesito and that allows to change sorting behavior of reviews

    For a basic description of logic and approach about this software development, have a look at the Medium post

    Monitoring functionality

    The monitor.py script can be used to have an incremental scraper and override the limitation about the number of reviews that can be retrieved. The only additional requirement is to install MongoDB on your laptop: you can find a detailed guide on the official site

    The script takes two input:

    • --i: same as monitor.py script
    • --from-date: string date in the format YYYY-MM-DD, gives the minimum date that the scraper tries to obtain

    The main idea is to periodically run the script to obtain latest reviews: the scraper stores them in MongoDB up to get either the latest review of previous run or the day indicated in the input parameter.

    Take a look to this Medium post to have more details about the idea behind this feature.

    Notes

    Url must be provided as expected, you can check the example file urls.txt to have an idea of what is a correct url. If you want to generate the correct url:

    1. Go to Google Maps and look for a specific place;
    2. Click on the number of reviews in the parenthesis;
    3. Save the url that is generated from previous interaction.