指定されたURLのPythonコードからYouTubeのタイトルと説明を取得するにはどうすればよいですか。YouTube APIを使用する必要がありますか?私は与えられたURLからタイトルと説明を生成することを見つける必要があるプログラムを書いています
5115 次
3 に答える
7
必須ではありませんが、独自に作成するよりもはるかに迅速かつ簡単です。
詳細については、https://developers.google.com/youtube/1.0/developers_guide_pythonを参照してください。
gdata
モジュールをインストールしたら、試してみてください
import gdata.youtube
import gdata.youtube.service
yt_service = gdata.youtube.service.YouTubeService()
# authorize - you need to sign up for your own access key, or be rate-limited
# yt_service.developer_key = 'ABCxyz123...'
# yt_service.client_id = 'My-Client_id'
def PrintEntryDetails(entry):
print 'Video title: %s' % entry.media.title.text
print 'Video published on: %s ' % entry.published.text
print 'Video description: %s' % entry.media.description.text
print 'Video category: %s' % entry.media.category[0].text
print 'Video tags: %s' % entry.media.keywords.text
print 'Video watch page: %s' % entry.media.player.url
print 'Video flash player URL: %s' % entry.GetSwfUrl()
print 'Video duration: %s' % entry.media.duration.seconds
for entry in yt_service.GetTopRatedVideoFeed().entry:
PrintEntryDetails(entry)
于 2012-07-04T01:44:00.987 に答える
6
URL リソースが使用できなくなったため、V2 API が使用できなくなったため、両方の答えが最初に機能しなくなりました。
これは機能している V3 コードです。
from apiclient.discovery import build
DEVELOPER_KEY = 'your api key goes here'
youtube = build('youtube', 'v3', developerKey=DEVELOPER_KEY)
ids = '5rC0qpLGciU,LgbuxTfJFr0'
results = youtube.videos().list(id=ids, part='snippet').execute()
for result in results.get('items', []):
print result['id']
print result['snippet']['description']
print result['snippet']['title']
于 2016-10-03T07:16:19.757 に答える
0
開発者キーを使用して YouTube によって追跡されることなく、自分で作成したい場合は、次の宛先にリクエストを送信できます。
https://gdata.youtube.com/feeds/api/videos/#{video_id}
https://gdata.youtube.com/feeds/api/videos/#{video_id}?alt=json
例: https://gdata.youtube.com/feeds/api/videos/fcz_DYms4N4。必要に応じて、XML、JSON、または JSONP を返すことができます。
于 2014-02-15T21:06:28.787 に答える