1.0.0 โข Published 5 months ago
gmaps-route-scraper v1.0.0
๐ฆ 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-scraper
Or via yarn:
yarn add gmaps-route-scraper
Usage ๐น๏ธ
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.
1.0.0
5 months ago