【发布时间】:2018-09-03 07:16:01
【问题描述】:
使用 Python,我需要读取 Gmail 帐户的总存储量,以跟踪从 Gmail 页面看到的已使用空间百分比。
例如:如果它说 10GB 的 15GB (66%) 比一个文件应该记录数字 - 66。
有可能吗?
提前致谢
【问题讨论】:
标签: python windows gmail storage
使用 Python,我需要读取 Gmail 帐户的总存储量,以跟踪从 Gmail 页面看到的已使用空间百分比。
例如:如果它说 10GB 的 15GB (66%) 比一个文件应该记录数字 - 66。
有可能吗?
提前致谢
【问题讨论】:
标签: python windows gmail storage
您可以使用 requests 库向 Google Drive 的 api 发出基本请求,因为邮件和驱动器共享相同的存储空间。您可以查看API的详细信息 here
import requests
import json
def main():
req = requests.get('https://www.googleapis.com/drive/v3/about?fields=storageQuota&key={YOUR_API_KEY}')
json_response = json.loads(req.content)
//Process the json response to your free will
if __name__ == '__main__':
main()
请求的结果是这样的
200 OK
- Hide headers -
cache-control: private, max-age=0, must-revalidate, no-transform
content-encoding: gzip
content-type: application/json; charset=UTF-8
date: Mon, 03 Sep 2018 08:42:33 GMT
expires: Mon, 03 Sep 2018 08:42:33 GMT
server: GSE
transfer-encoding: chunked
vary: Origin, X-Origin
{
"storageQuota": {
"limit": "16106127360",
"usage": "15054153867",
"usageInDrive": "15022609247",
"usageInDriveTrash": "0"
}
}
【讨论】: