Dropbox vs Google Docs?



想把一些沒有提供RSS服務的網站,將網站內容節錄成RSS feed,不過feed弄出來後要放哪?
 當初考慮的是Google Drive,不過看到那讓人蛋疼的API......跳過...= =

Dropbox. API很簡潔。

其實節錄網站內容的程式碼用BeautifulSoup寫沒幾行,如果用Google Docs API, 上傳那部份的程式碼,都比節錄網站的那段還多...... 想想還是別自虐好了。

example中有個cli_client.py的範例。Dropbox API能做什麼,都在這範例中了。

其中有段 load_creds(self)比較重要,會紀錄access token。
這樣就不需要每次都重新取得授權。
而要取得access token直接用這隻程式的login指令就好。
class StoredSession(session.DropboxSession):
"""a wrapper around DropboxSession that stores a token to a file on disk""" TOKEN_FILE = "token_store.txt"
def load_creds(self):
try:
stored_creds = open(self.TOKEN_FILE).read()
self.set_token(*stored_creds.split('|'))
print "[loaded access token]"
except IOError:
pass # don't worry if it's not there

def write_creds(self, token):

f = open(self.TOKEN_FILE, 'w') f.write("|".join([token.key, token.secret])) f.close()

參考文章:

沒有留言:

張貼留言