
Google Maps Itinerary
- alexey/google-maps-itinerary
- Modified
- Users 20
- Runs 437
- Created by
Alexey Udovydchenko
Scrapes a Google Maps itinerary by direct URL for the fastest trip duration, distance, and name.
To run the code examples, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token. For a more detailed explanation, please read about running actors via the API in Apify Docs.
import { ApifyClient } from 'apify-client';
// Initialize the ApifyClient with API token
const client = new ApifyClient({
token: '<YOUR_API_TOKEN>',
});
// Prepare actor input
const input = {
"startUrls": [
{
"url": "https://www.google.com/maps/dir/Supermercado+Suma+Can+Corona,+Plaça+Espanya,+1,+07109+Fornalutx,+Balearic+Islands/07315+Escorca,+Balearic+Islands/@39.8140347,2.2493611,186969m/am=t/data=!3m1!1e3!4m14!4m13!1m5!1m1!1s0x1297e87f07000fad:0x8d6897747207d0bf!2m2!1d2.7412712!2d39.782408!1m5!1m1!1s0x1297dd95bfd7ce11:0xb8c0845ebf64f442!2m2!1d2.7954122!2d39.8409277!3e0?hl=en"
}
]
};
(async () => {
// Run the actor and wait for it to finish
const run = await client.actor("alexey/google-maps-itinerary").call(input);
// Fetch and print actor results from the run's dataset (if any)
console.log('Results from dataset');
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
console.dir(item);
});
})();