检查Gmail帐户是为了跟踪使用Python的百分比

问题描述 投票:1回答:1

使用Python,我需要阅读Gmail帐户的总存储量,以便跟踪从Gmail页面看到的百分比使用的空间。

示例:如果它表示10GB的15GB(66%)应该记录数字 - 66。

可能吗?

提前致谢

python windows gmail storage
1个回答
1
投票

您可以使用请求lib并向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"
 }
}
© www.soinside.com 2019 - 2024. All rights reserved.