gmaps-route-scraper
v1.0.0
Published
Scrape Google Maps travel details using Puppeteer.
Downloads
121
Maintainers
Readme
🚦 gmaps-route-scraper
A lightweight Node.js package that scrapes travel duration & distance from Google Maps.
Simply call the function with a source, destination, and mode, and get the travel details in JSON format.
Installation 🔌
Install via npm:
npm install gmaps-route-scraperOr via yarn:
yarn add gmaps-route-scraperUsage 🕹️
Simply import the package and call the getRouteDetails function:
const { getRouteDetails } = require("gmaps-route-scraper");
(async () => {
try {
const route = await getRouteDetails("Virar East", "Olympus-A", "Driving");
console.log(route);
} catch (error) {
console.error("Error:", error.message);
}
})();Available Travel Modes 🚗 🚲 🚶♂️
| Mode | Description |
|--------------|-----------------------------|
| "Driving" | Travel by car |
| "Two-wheeler" | Travel by bike/scooter |
Output 📲
The function returns a JSON object with travel details:
{
"mode": "Driving",
"time": "42 min",
"distance": "18 km"
}If no route is found, it returns:
{
"message": "No Driving route found"
}Notes ⚠️
- Google Maps UI may change, affecting the scraping.
- Puppeteer may require extra setup on some servers.
- Use responsibly—excessive requests may get blocked by Google.
License 📜
This project is MIT Licensed.
