简体   繁体   English

使用Python从Google日历中提取信息

[英]Extracting information from a Google Calendar using Python

Summary: 摘要:

I'd like to use a Python script to automatically download events from a Google Calendar. 我想使用Python脚本自动从Google日历下载事件。

Detail: 详情:

I am making a Kindle based Heads-up display. 我正在制作基于Kindle的Heads-up显示器。 The Kindle runs a python script every hour, and downloads weather and event information from the web. Kindle每小时运行一次python脚本,并从网上下载天气和事件信息。 I'd also like it to fetch events for my kids' school . 我也希望它能为我的孩子的学校筹办活动 However, they are all on a Google Calendar, and I can't seem to find a way to download the events using Python. 但是,它们都在Google日历上,我似乎找不到找到使用Python下载事件的方法。

What I have tried so far: 到目前为止我尝试过的是:

I have tried the example code here: https://developers.google.com/google-apps/calendar/quickstart/python but it needs a client_secret.json file. 我在这里尝试了示例代码: https : //developers.google.com/google-apps/calendar/quickstart/python,但它需要一个client_secret.json文件。

I tried the suggested Wizard: https://console.developers.google.com/flows/enableapi?apiid=calendar but this feels like I'm getting into something too deep. 我尝试了建议的向导: https : //console.developers.google.com/flows/enableapi?apiid=calendar,但这感觉就像是我进入的东西太深了。

Isn't there just a way to fetch some events from a public calendar? 是否不存在从公共日历中获取某些事件的方法? I would even be happy to just copy/paste the text from the Agenda view of the calendar. 我什至会很乐意从日历的“议程”视图中复制/粘贴文本。 If my browser can get this data, surely there must be a way. 如果我的浏览器可以获取此数据,那么肯定有一种方法。

Added: I am a complete newbie using things like Google Developers APIs, OAuth, etc. 补充:我是一个完全的新手,使用Google Developers API,OAuth等功能。

Wow, after a lot of digging, I discovered that it's easy ! 哇,经过大量的挖掘,我发现这很容易 I can't believe nothing online mentions this. 我简直不敢相信网上没有提及这一点。

I only discovered this when I created my own calendar, and found, in the settings page, there's a link to download my calendar in XML, ICAL or HTML format. 我只有在创建自己的日历时才发现此问题,并在设置页面中找到了一个链接,可以下载XML,ICAL或HTML格式的日历。 So I just replaced the name of the calendar with that of the public calendar I want to use, and it worked! 因此,我只是将日历的名称替换为我要使用的公共日历的名称,它起作用了!

XML ICAL和HTML格式的Google日历

https://www.google.com/calendar/feeds/NAME_OF_CALENDAR%40googlemail.com/public/basic

You can use the official API for Google calendar. 您可以使用Google日历的官方API。 More details, including documentation is provided at https://developers.google.com/api-client-library/python/apis/calendar/v3?hl=en https://developers.google.com/api-client-library/python/apis/calendar/v3?hl=zh_CN提供了包括文档在内的更多详细信息。

The .json file can be downloaded when you enable the api in the settings. 在设置中启用api后,可以下载.json文件。 As far as I know, this step cannot be done on a mobile device. 据我所知,这一步骤无法在移动设备上完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM