Google Direction Scraper
1 day trial then $12.00/month - No credit card required now
Google Direction Scraper
1 day trial then $12.00/month - No credit card required now
This actor automates extracting route directions from Google Maps. Using Node.js and Puppeteer, it retrieves travel routes, distances, and estimated times for various transport modes, offering structured data for navigation, logistics, or travel planning applications.
This Apify actor scrapes detailed directions from Google Maps, providing route information such as distance, travel time, and step-by-step instructions for various modes of transportation (driving, walking, cycling, public transport, etc.). This is useful for generating route data for apps, transportation analysis, or travel planning.
Features
-
Input: Provide starting and destination locations (either as addresses or coordinates).
-
Modes of Transport: Supports multiple modes of transportation: Driving, Walking, Cycling, Flight, Transit, Two Wheeler,
-
Detailed Route Information: Retrieves essential route details: Total distance, Estimated travel time, Step-by-step directions (turn-by-turn), Transportation mode (e.g., driving, walking, cycling), Estimated arrival time for public transportation, Directions with Google Maps link,
-
Output Formats: Results are available in JSON format for easy integration and further use.
How It Works
This actor queries Google Maps for directions between the specified origin and destination locations and parses the results to extract key details about the route, travel time, distance, and steps.
Input
The input is a JSON object that includes the following fields:
1{ 2 "source": "New York", 3 "destination": "Washington" 4}
- source: The starting location for the route (can be an address or coordinates).
- destination: The destination location for the route (can be an address or coordinates).
Output
The output is a JSON object containing detailed route information for the trip. Here’s an example of what the output might look like:
1[{ 2 "source": "New York", 3 "destination": "Washington", 4 "mode": { 5 "best": [ 6 { 7 "mode": "Driving", 8 "duration": "43 hr", 9 "metre": "2,919 miles", 10 "direction": "via I-80 W", 11 "means": null, 12 "info": "43 hr without traffic\n This route has tolls.\n Your destination is in a different time zone." 13 }, 14 { 15 "mode": "Driving", 16 "duration": "43 hr", 17 "metre": "2,923 miles", 18 "direction": "via I-40 W", 19 "means": null, 20 "info": "43 hr without traffic" 21 }, 22 { 23 "mode": "Flights", 24 "duration": "7 hr 35 min", 25 "metre": null, 26 "direction": "New York, NY—Fresno, CA", 27 "means": null, 28 "info": null 29 } 30 ], 31 "walk": [ 32 { 33 "mode": "Walking", 34 "duration": "1,033 hr", 35 "metre": "2,830 miles", 36 "direction": "via IA-2 E", 37 "means": null, 38 "info": " This route includes a ferry.\n This route has restricted usage or private roads.\n Your destination is in a different time zone." 39 } 40 ], 41 "driving": [ 42 { 43 "mode": "Driving", 44 "duration": "43 hr", 45 "metre": "2,919 miles", 46 "direction": "via I-80 W", 47 "means": null, 48 "info": "43 hr without traffic\n This route has tolls.\n Your destination is in a different time zone." 49 }, 50 { 51 "mode": "Driving", 52 "duration": "43 hr", 53 "metre": "2,923 miles", 54 "direction": "via I-40 W", 55 "means": null, 56 "info": "43 hr without traffic" 57 }, 58 { 59 "mode": "Driving", 60 "duration": "43 hr", 61 "metre": "2,954 miles", 62 "direction": "via I-70 W", 63 "means": null, 64 "info": "43 hr without traffic" 65 } 66 ], 67 "two-wheeler": null, 68 "transit": null, 69 "flight": [ 70 { 71 "mode": "Flights", 72 "duration": "7 hr 35 min+ - from $481", 73 "metre": null, 74 "direction": "New York, NY—Fresno, CA", 75 "means": null, 76 "info": null 77 } 78 ], 79 "cycling": [ 80 { 81 "mode": "Cycling", 82 "duration": "296 hr", 83 "metre": "3,533 miles", 84 "direction": "via Empire State Trl", 85 "means": null, 86 "info": " This route includes a ferry.\n This route crosses through Canada.\n This route has restricted usage or private roads.\n Your destination is in a different time zone." 87 } 88 ] 89 } 90}]
Key Scraped Data
- Source: Starting location.
- Destination: Final destination.
- Distance: Total distance of the route.
- **Duration: Estimated travel time.
- Mode of Transport: Driving, walking, cycling, or transit.
- Steps: Turn-by-turn directions for each leg of the journey.
Output Formats
JSON
Usage
#On the Apify Platform
- Go to the Google Direction Scraper actor on Apify.
- Click Try for Free.
- Provide the origin, destination, and mode of transport.
- Run the actor and wait for it to complete.
- Download the results in your preferred format (JSON).
Locally via Apify CLI
- Install Apify CLI.
- Run the actor locally using the following command:
apify run your-username/google-direction-scraper --input='{"source": "New York", "destination": "Washington"}'
Input Example
1{ 2 "source": "New York", 3 "destination": "Washington" 4}
This input will fetch the directions from New York to Washington.
Use Cases
- Travel and Route Planning: Get detailed directions between locations for driving, walking, or public transport.
- Logistics and Transportation: Automate route generation for delivery services, ridesharing, or commuting apps.
- Research and Analysis: Extract travel time and distance data for city planning, transportation studies, or efficiency improvements.
Limitations
- Only fetches directions available via Google Maps.
- Public transportation data may vary based on the region and time of day.
Actor Metrics
1 monthly user
-
1 star
>99% runs succeeded
Created in Oct 2024
Modified 2 months ago