展望同樣的問題,我找到了有關Python YouTube API的this question的答案。
內容Feed查詢返回單個結果塊。您可以使用GetNextLink方法檢索下一個塊(如果有的話)。這在「查詢結果」下的Data API protocol reference中進行了描述。
這是一個Python解決方案(針對Google Apps的Legacy OAuth),它依賴於前面提到的YouTube API問題的答案。
CONSUMER_KEY = 'some_key'
CONSUMER_SECRET = 'some_secret'
REQUESTOR_ID = '[email protected]' + CONSUMER_KEY
DOMAIN = 'some_domain'
def content_generator(client):
content_feed = client.GetContentFeed()
while content_feed is not None:
for content in content_feed.entry:
yield content
next_link = content_feed.GetNextLink()
if next_link is None:
content_feed = None
else:
content_feed = client.GetContentFeed(next_link.href)
client = gdata.sites.client.SitesClient(source='some_source', site=SITE, domain=DOMAIN)
client.auth_token = gdata.gauth.TwoLeggedOAuthHmacToken(CONSUMER_KEY, CONSUMER_SECRET, REQUESTOR_ID)
for page in content_generator(client):
# do something
print(page.page_name)