1.0.0 โ€ข Published 5 months ago

gmaps-route-scraper v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

๐Ÿšฆ 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.

gmaps-route-scraper


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 ๐Ÿš— ๐Ÿšฒ ๐Ÿšถโ€โ™‚๏ธ

ModeDescription
"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