bash – 每天WGET您的谷歌位置记录
我想定期保存我的谷歌位置记录.
通常我使用Web接口: 它还提供了一个导出数据的链接,如下所示: https://maps.google.com/locationhistory/b/0/kml?startTime=1376604000000&endTime=1376690400000 如何每天下载此链接(及其固定的时间戳),包括使用WGET或curl登录? 简单地说它给我带来了302 Moved Temporarily
您将获得302 Moved Temporarily,因为您需要进行身份验证:Google正在将您重定向到其登录页面.
经过身份验证后,Google凭据会存储在浏览器Cookie中.如果您要下载Google地图位置历史记录链接,则必须提供带卷曲的浏览器Cookie. curl的-b选项允许您使用相对于Netscape/Mozilla cookie file format的cookies.txt.
因此,最简单的解决方案是将浏览器cookie导出到cookies.txt文件并指示curl使用它们.在Chrome中,Cookie存储在sqlite3数据库中.您可以使用以下命令导出它们: 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,例如限制导出Cookie的“%google.com”. 使用-b /tmp/cookies.txt调用curl以使用导出的cookie并对googles地图进行身份验证,您将能够下载google地图位置历史记录 curl -b /tmp/cookies.txt https://maps.google.com/locationhistory/b/0/kml?startTime=1376604000000&;endTime=1376690400000 要避免将cookie存储在临时文件中,请使用以下命令: curl -b <(sqlite3 ~/.config/google-chrome/Default/Cookies 'select host_key,value from cookies' | tr '|' 't') https://maps.google.com/locationhistory/b/0/kml?startTime=1376604000000&;endTime=1376690400000 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |