2010-04-01 109 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