I want to save my google location history in a regular basis.
Usually I use the Webinterface: https://maps.google.com/locationhistory/b/0
it also provides a link to export data which looks like that:
https://maps.google.com/locationhistory/b/0/kml?startTime=1376604000000&endTime=1376690400000
How can I download this link (and its according timestamps fixed) daily including logging in using WGET or curl?
Simply wget it brought me an 302 Moved Temporarily
You get a
302 Moved Temporarily
because you need to be authenticated: Google is redirecting you to its login page.Once authenticated, google credentials are stored in browser cookies. If you want to download the Google maps location history link, then you have to provide browser cookies with
curl
. The-b
option ofcurl
allows you to use acookies.txt
with respect to Netscape/Mozilla cookie file format.So the simplest solution is to export your browser cookies to a
cookies.txt
file and instructcurl
to use them. In Chrome, cookies are stored in a sqlite3 database. You can export them with the following command:Note the
host_key like "%google.com"
which limits exported cookies.Invoke
curl
with-b /tmp/cookies.txt
to use the exported cookies and authenticate to googles maps and you will be able to download the google maps location historyTo avoid storing your cookies in a temporary file, use this command:
Replying late on this, but may be this will also help someone else:
Another easy way to export cookie is to first login on chrome using google username and password then use this extension export cookie to export cookie into a file. After that you can use this file with wget to download document with --load-cookies options like: