-
-
Save benjibee/37e0031a8aa7a25e9814a01bdb03217c to your computer and use it in GitHub Desktop.
// This script is meant to import Google Maps starred places into | |
// another Google account. | |
// Given a geoJSON file of Google Maps starred places (places.json) | |
// exported by Google takeout (account backup) this script should | |
// open each place URL and manually click save. | |
// Upon first run, it's best to stop it and manually login to your | |
// Google account otherwise you'll run into a non-verified device | |
// issue. Run again and it should continue through with problems. | |
// Make sure to enter you Google account name and password (purge after use!) | |
// To init, run npm i -D puppeteer and then node scrape.js | |
const puppeteer = require('puppeteer'); | |
const fs = require('fs'); | |
const GOOGLE_ACCOUNT_ID = ''; | |
const GOOGLE_ACCOUNT_PASS = ''; | |
const jsonFile = fs.readFileSync(__dirname + '/places.json'); | |
const jsonData = JSON.parse(jsonFile); | |
let scrape = async () => { | |
const browser = await puppeteer.launch({headless: false}); | |
const page = await browser.newPage(); | |
await page.goto('https://accounts.google.com/', {waitUntil: 'networkidle2'}); | |
const result = await page.evaluate(() => { | |
document.getElementById('identifierId').value = GOOGLE_ACCOUNT_ID; | |
document.getElementById('identifierNext').click(); | |
window.setTimeout(function(){ | |
document.querySelectorAll("[name='password'")[0].value = GOOGLE_ACCOUNT_PASS; | |
document.getElementById('passwordNext').click(); | |
}, 250); | |
return; | |
}); | |
await page.waitFor(4000) | |
for (let index in jsonData.features) { | |
let place = jsonData.features[index].properties["Google Maps URL"]; | |
let name = jsonData.features[index].properties["Location"]["Business Name"]; | |
await page.goto(place, {waitUntil: 'networkidle2'}); | |
await page.evaluate(() => { | |
if (typeof(document.querySelectorAll("[aria-label='SAVE']")[0]) != 'undefined') { | |
document.querySelectorAll("[aria-label='SAVE']")[0].click(); | |
window.setTimeout(function(){ | |
document.querySelectorAll("[data-index='2']")[0].click(); | |
}, 50); | |
console.log('Added "' + name + '" to your starred places!'); | |
} else { | |
console.log('Skipping "' + name + '" as it was already starred…'); | |
} | |
return; | |
}); | |
await page.waitFor(200) | |
} | |
browser.close(); | |
return; | |
}; | |
scrape().then((value) => { | |
console.log('All done!'); | |
}); |
Hey @benjibee, thanks for publishing this gist! I needed to make some updates to it to get it to work with the latest version of Puppeteer, and ended up turning it into a CLI utility that can handle importing to different Google Maps lists using either the Starred Places GeoJSON or Saved Places (i.e. the 'Favorites', 'Want To Go' or any user-created places lists) CSV data that Google Takeout produces.
You can find it here: https://github.com/robinnorth/google-migration-utils. I've made sure to credit you in the README, hope that's OK!
That's really great to hear! I used this once a few years ago so if it's still somehow helpful that makes me really happy. Thanks for the credit and next time I need this I'll give your tool a try :)
@benjibee, yeah it's very much a one-time use kinda tool, isn't it? I have now successfully migrated my old Google Workspace account to a new personal Google account using it, saving me the pain of losing all my starred places and custom lists I'd spent years accumulating, so it was indeed very helpful, thanks!
@benjibee @robinnorth I've managed to export the "Saved places" using Takeout, although, how did you managed to export the other custom lists?
@benjibee @robinnorth I've managed to export the "Saved places" using Takeout, although, how did you managed to export the other custom lists?
Just found out that custom Google Maps lists reside in CSV format in the “Saved” option of Google Takeout.
@benjibee @robinnorth I've managed to export the "Saved places" using Takeout, although, how did you managed to export the other custom lists?
Just found out that custom Google Maps lists reside in CSV format in the “Saved” option of Google Takeout.
That's really great to know, thanks for following up on your issue!
As for your previous issue, when I wrote this Google Maps didn't have more than one type of list, only "Starred" so I don't know how to work with the others.
Hello @benjibee @robinnorth - I am not a coder by any means, but this is a valuable thing to implement as my old google account has my map data and I want to transfer it over. Would you be so kind as to write a quick "how to" implement this code? Hope it's not to troublesome.
Hey @TreJoren, take a look at https://github.com/robinnorth/google-migration-utils. Download the source of the repo and follow the README instructions to run the Maps import tool from a command prompt, no coding required.
You'll need to have Node LTS and npm installed (npm is included with Node) to run it. Take a look at https://nodesource.com/blog/installing-nodejs-tutorial-windows/ for a tutorial on getting it all set up.
Hey @TreJoren, take a look at https://github.com/robinnorth/google-migration-utils. Download the source of the repo and follow the README instructions to run the Maps import tool from a command prompt, no coding required.
You'll need to have Node LTS and npm installed (npm is included with Node) to run it. Take a look at https://nodesource.com/blog/installing-nodejs-tutorial-windows/ for a tutorial on getting it all set up.
I still don’t understand how I’m supposed to after I installed NODE JS on my computer…..I have no idea after reading READ ME…what do I do with ‘ yarn ‘ where to put it..could you please be so kind to offer a step by step tutorial for crying person with zero knowledge of it… thank you so much ( me crying ugly face )😭
Hey @benjibee, thanks for publishing this gist! I needed to make some updates to it to get it to work with the latest version of Puppeteer, and ended up turning it into a CLI utility that can handle importing to different Google Maps lists using either the Starred Places GeoJSON or Saved Places (i.e. the 'Favorites', 'Want To Go' or any user-created places lists) CSV data that Google Takeout produces.
You can find it here: https://github.com/robinnorth/google-migration-utils. I've made sure to credit you in the README, hope that's OK!