如何从 shell 下载所有谷歌文档
我学会了如何下载单个谷歌文档。但我正在尝试制作一个脚本,以文本格式下载所有数据,然后将它们合并到 1 个文本文件中。所以,我想知道如何实现下载部分,以便 1 可以像使用网络浏览器一样获取包含我所有文件的 zip 文件。这是我的新脚本来获取单个文件。希望您能提出一些调整建议,使其更加有效。
#!/bin/bash
token=$(curl -s https://www.google.com/accounts/ClientLogin -d [email protected] -d Passwd=blahblah -d accountType=GOOGLE -d service=writely -d Gdata-version=3.0 |cut -d "=" -f 2)
set $token
wget --header "Gdata-Version: 3.0" --header "Authorization: GoogleLogin auth=$3" "https://docs.google.com/feeds/download/documents/Export?docID=${resourceId}&exportFormat=txt" -O /tmp/${file[$i]}.txt
如您所见,这里我指定了单个 resourceId。我应该在下载链接中推送许多 resourceId-s 来获取全部资源还是有更好的方法?
I learned how to download single google doc. But I am trying to make a script that downloads all my data in text format and then merges them in 1 text file. So, I wonder how to implement downloading part so that 1 can get zip file with all my files just as you do with web browser. Here is my newb script to get single file. Hope you can suggest some tweaks that make it more effective.
#!/bin/bash
token=$(curl -s https://www.google.com/accounts/ClientLogin -d [email protected] -d Passwd=blahblah -d accountType=GOOGLE -d service=writely -d Gdata-version=3.0 |cut -d "=" -f 2)
set $token
wget --header "Gdata-Version: 3.0" --header "Authorization: GoogleLogin auth=$3" "https://docs.google.com/feeds/download/documents/Export?docID=${resourceId}&exportFormat=txt" -O /tmp/${file[$i]}.txt
Here I specify single resourceId, as you see. Should I just push many resourceId-s in download link to get them all or there is better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不介意使用非本机工具,我强烈推荐:http://code.google .com/p/googlecl/
但是,考虑到这个问题的年龄,您可能已经弄清楚了这一点。
If you don't mind using a non-native tool I would highly recommend: http://code.google.com/p/googlecl/
However, considering the age of this question, you may have already figured this out.
您还可以使用文档列表 API 的存档 Feed 将文档导出为 zip 文件:
https://developers.google.com/google-apps/documents-list/#managing_archives_of_documents_and_files
You can also use the Archive feed of the Documents List API to export your documents as a zip file:
https://developers.google.com/google-apps/documents-list/#managing_archives_of_documents_and_files