问题描述
我要救我的谷歌位置历史定期。
I want to save my google location history in a regular basis.
我通常使用Webinterface:
Usually I use the Webinterface:https://maps.google.com/locationhistory/b/0
它也提供了一个链接,导出数据,看起来像:
it also provides a link to export data which looks like that:
<一个href=\"https://maps.google.com/locationhistory/b/0/kml?startTime=1376604000000&endTime=1376690400000\" rel=\"nofollow\">https://maps.google.com/locationhistory/b/0/kml?startTime=1376604000000&endTime=1376690400000
我怎样才能下载此链接(其根据时间戳固定)每天包括日志记录使用wget或curl?
How can I download this link (and its according timestamps fixed) daily including logging in using WGET or curl?
只要wget的它给我带来的 302暂时移动
Simply wget it brought me an 302 Moved Temporarily
推荐答案
您获得 302暂时移动
,因为你需要进行身份验证:谷歌正在将您重定向到其登录页。
You get a 302 Moved Temporarily
because you need to be authenticated: Google is redirecting you to its login page.
一旦通过验证,谷歌凭据存储在浏览器的cookies。如果你想下载谷歌地图的位置历史记录的链接,那么你必须提供浏览器的cookies卷曲
。 的
,您可以使用 -b
选项卷曲 cookie.txt的
关于。
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 of curl
allows you to use a cookies.txt
with respect to Netscape/Mozilla cookie file format.
在 cookie.txt的
有七个选项卡分隔的字段中的每一行:
- 域 - 创建,并且可以读取变量的域。
- 标志 - 指示是否在给定域中的所有计算机都可以访问的变量A TRUE / FALSE值。这个值是由浏览器自动设置,这取决于你的域设置的值。
- 路径 - 这个变量是有效的域中的路径。
- 安全 - 真/假值,表示如果与域安全连接需要*访问变量。
- 过期 - UNIX的时间变量将在到期。 UNIX时间定义为自1970年1月1日00:00:00 GMT的秒数。
- 名称 - 变量的名称。
- 值 - 变量的值 。
- domain - The domain that created AND that can read the variable.
- flag - A TRUE/FALSE value indicating if all machines within a given domain can access the variable. This value is set automatically by the browser, depending on the value you set for domain.
- path - The path within the domain that the variable is valid for.
- secure - A TRUE/FALSE value indicating if a secure connection with the domain is needed to * access the variable.
- expiration - The UNIX time that the variable will expire on. UNIX time is defined as the number of seconds since Jan 1, 1970 00:00:00 GMT.
- name - The name of the variable.
- value - The value of the variable.
所以,简单的解决方案是将您的浏览器cookie导出到 cookie.txt的
文件和指示卷曲
使用他们。在Chrome中,Cookie被存储在一个数据库sqlite3的。你可以用下面的命令将它们导出:
So the simplest solution is to export your browser cookies to a cookies.txt
file and instruct curl
to use them. In Chrome, cookies are stored in a sqlite3 database. You can export them with the following command:
sqlite3 ~/.config/google-chrome/Default/Cookies \
'select host_key, "TRUE", path, "FALSE", expires_utc, name, value from cookies where host_key like "%google.com"' \
| tr '|' '\t' > /tmp/cookies.txt
请注意在 host_key如%google.com
这限制出口饼干。
Note the host_key like "%google.com"
which limits exported cookies.
调用卷曲
与 -b /tmp/cookies.txt
来使用导出的cookie和验证到谷歌地图你将能够下载谷歌地图的位置历史记录
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 history
curl -b /tmp/cookies.txt https://maps.google.com/locationhistory/b/0/kml\?startTime\=1376604000000\&endTime\=1376690400000
要避免存放在一个临时文件你的cookies,使用这个命令:
To avoid storing your cookies in a temporary file, use this command:
curl -b <(sqlite3 ~/.config/google-chrome/Default/Cookies 'select host_key, "TRUE", path, "FALSE", expires_utc, name, value from cookies' | tr '|' '\t') https://maps.google.com/locationhistory/b/0/kml\?startTime\=1376604000000\&endTime\=1376690400000
这篇关于WGET您的谷歌的位置,每天历史的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!