@openrol/maps-scrap
v0.1.0
Published
Powerful Maps scraping library and CLI built with Playwright
Maintainers
Readme
@openrol/maps-scrap
Maps scraping library and CLI built on Playwright.
It is designed to be usable in two ways:
- as a small library with a clean
scrapeMaps()API - as a CLI for quick dataset export to
json,jsonl, orcsv
Installation
npm install @openrol/maps-scrap playwright
npx playwright install chromiumLibrary Usage
import { scrapeMaps } from "@openrol/maps-scrap";
const result = await scrapeMaps({
query: "coffee shops in Jakarta",
limit: 25,
headless: true,
});
console.log(result.collected);
console.log(result.places[0]);Reusable scraper instance
import { createMapsScraper } from "@openrol/maps-scrap";
const scraper = createMapsScraper({
headless: true,
language: "en",
maxScrolls: 80,
});
const restaurants = await scraper.scrape({
query: "turkish restaurants in toronto",
limit: 20,
});Export scraped places
import { scrapeMaps, writePlaces } from "@openrol/maps-scrap";
const result = await scrapeMaps({
query: "barber shops in Surabaya",
limit: 50,
});
await writePlaces(result.places, {
filePath: "./data/barbers.csv",
});CLI Usage
npx maps-scrap --query "coffee shops in Jakarta" --limit 25 --output ./coffee.jsonCommon examples
npx maps-scrap --query "gyms in Surabaya" --limit 100 --output ./gyms.csv
npx maps-scrap --query "nail salons in Bali" --limit 50 --output ./nails.jsonl --append
npx maps-scrap --query "restaurants in Bandung" --limit 20 --headed --jsonAPI
scrapeMaps(options)
Main function for scraping map listings.
Important options:
query: search phrase to run in the maps search UIlimit: number of places to collect, default20headless: run with or without a visible browser, defaulttruelanguage: locale hint for Maps UI, defaultencountry: optional country hintmaxScrolls: maximum listing feed scroll passes, default50scrollDelayMs: delay between feed scrollslistingDelayMs: delay after opening a place detail panelnavigationTimeoutMs: initial page/search timeoutdetailTimeoutMs: place detail timeoutdedupe: remove duplicate listings byname + address, defaulttruelogger: pass your own logger objectonProgress: receive progress callbacks while scraping
Returned shape:
type MapsScrapeResult = {
query: string;
requested: number;
found: number;
collected: number;
durationMs: number;
places: Place[];
};writePlaces(places, options)
Writes scraped places to disk.
filePath: output locationformat: optionaljson | jsonl | csvappend: supported forjsonandjsonl
If format is omitted, it is inferred from the file extension.
Extracted fields
Each Place contains:
nameaddresswebsitephone_numberreviews_countreviews_averagestore_shoppingin_store_pickupstore_deliveryplace_typeintroduction
Publishing
Build the package before publishing:
bun run build
npm publish --access publicNotes
- Target site markup changes over time. Selector maintenance is part of owning this package.
- Use reasonable scrape volume and pacing to reduce blocking or rate limiting.
csvexport currently writes the current run output; append mode is intended forjsonandjsonl.
License
MIT
