如何从给定 url 的 python 代码中获取 YouTube 标题和描述。是否需要使用youtube API?我正在编写一个程序,需要从给定的网址查找生成标题和描述
它不是必要的,但它可能比您自己编写要快得多且容易得多。
有关更多信息,请参阅https://developers.google.com/youtube/1.0/developers_guide_python 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)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)