2010-04-01 68 views
0

由于gmail和任务API在任何地方都不可用(例如:一些公司阻止Gmail而不是日历),有没有办法通过日历Web界面取消谷歌任务?通过谷歌日历网络抓取谷歌任务

我不喜欢下面的一个userscript,但我觉得它太脆:

// List of div to hide 
idlist = [ 
    'gbar', 
    'logo-container', 
    ... 
]; 

// Hiding by id 
function displayNone(idlist) { 
    for each (id in idlist) { 
     document.getElementById(id).style.display = 'none'; 
    } 
} 
+0

也许吧。你有什么尝试?对不起,SO不是'requirements => code'引擎。 – 2010-04-01 21:59:35

+0

我试图做一个greasmonkey/jquery脚本.hide()所有不必要的日历div,但我不喜欢这个解决方案(它的脆弱)。我试着看看谷歌日历js代码,了解ajax调用,但它太复杂了。如果有更简单/干净的方式来访问我的数据,那就太好了。 – ideotop 2010-04-01 22:24:42

回答

0

我建议你解析希望看到的日历的Atom feed。您可以通过选择“选项齿轮”>“日历设置”,然后选择“日历”选项卡并选择所需的日历来获取各个日历的供稿。从“日历详细信息”屏幕中,您可以获取Atom(XML)提要,iCal提要或HTML/Javascript日历。

1

Google Tasks API现在可用。您可以通过HTTP查询获取任务列表,结果以JSON形式返回。有关于如何在

http://code.google.com/appengine/articles/python/getting_started_with_tasks_api.html

样品的webapp写在谷歌应用程序引擎谷歌的任务Web应用程序一步步的例子是这样的:

from google.appengine.dist import use_library 
use_library('django', '1.2') 
from google.appengine.ext import webapp 
from google.appengine.ext.webapp import template 
from google.appengine.ext.webapp.util import run_wsgi_app 
from apiclient.discovery import build 
import httplib2 
from oauth2client.appengine import OAuth2Decorator 
import settings 

decorator = OAuth2Decorator(client_id=settings.CLIENT_ID, 
          client_secret=settings.CLIENT_SECRET, 
          scope=settings.SCOPE, 
          user_agent='mytasks') 


class MainHandler(webapp.RequestHandler): 

    @decorator.oauth_aware 
    def get(self): 
    if decorator.has_credentials(): 
     service = build('tasks', 'v1', http=decorator.http()) 
     result = service.tasks().list(tasklist='@default').execute() 
     tasks = result.get('items', []) 
     for task in tasks: 
     task['title_short'] = truncate(task['title'], 26) 
     self.response.out.write(template.render('templates/index.html', 
               {'tasks': tasks})) 
    else: 
     url = decorator.authorize_url() 
     self.response.out.write(template.render('templates/index.html', 
               {'tasks': [], 
               'authorize_url': url})) 


def truncate(string, length): 
    return string[:length] + '...' if len(string) > length else string 

application = webapp.WSGIApplication([('/', MainHandler)], debug=True) 


def main(): 
    run_wsgi_app(application) 

注意,首先你需要启用Google API Tasks API https://code.google.com/apis/console/b/0/?pli=1