检索有关链接的有用信息。
Embeder的Python项目详细描述
获取网页的元信息并嵌入其内容的库。
通常当你在facebook或twitter上发布视频时会发生什么。
用法
命令行:
$ python embed.py http://www.youtube.com/watch?v=-r3VuOyr9lk { 'default': { 'desc': 'SERJ TANKIAN PERFORMING HONKING ANTELOPE Ft APO(AUCKLAND PHILHARMONIA ORCHESTRA) HD QUALITY "ELECT THE DEAD SYMPHONY" DVD RIP{2010}', 'title': u'Serj Tankian - Honking Antelope {Elect The Dead Symphony} (HD/DVD Quality) - YouTube'}, 'global': { 'desc': 'SERJ TANKIAN PERFORMING HONKING ANTELOPE Ft APO(AUCKLAND PHILHARMONIA ORCHESTRA) HD QUALITY "ELECT THE DEAD SYMPHONY" DVD RIP{2010}', 'picture_height': 360, 'picture_url': 'http://i1.ytimg.com/vi/-r3VuOyr9lk/maxresdefault.jpg', 'picture_width': 480, 'title': 'Serj Tankian - Honking Antelope {Elect The Dead Symphony} (HD/DVD Quality)', 'video_height': '720', 'video_url': 'https://www.youtube.com/embed/-r3VuOyr9lk', 'video_width': '960'}, 'oembed': { u'author_name': u'ObeyYourSysteM', u'author_url': u'http://www.youtube.com/user/ObeyYourSysteM', u'height': 344, u'html': u'<iframe width="459" height="344" src="http://www.youtube.com/embed/-r3VuOyr9lk?feature=oembed" frameborder="0" allowfullscreen></iframe>', u'provider_name': u'YouTube', u'provider_url': u'http://www.youtube.com/', u'thumbnail_height': 360, u'thumbnail_url': u'http://i1.ytimg.com/vi/-r3VuOyr9lk/hqdefault.jpg', u'thumbnail_width': 480, u'title': u'Serj Tankian - Honking Antelope {Elect The Dead Symphony} (HD/DVD Quality)', u'type': u'video', u'version': u'1.0', 'video_url': 'http://www.youtube.com/embed/-r3VuOyr9lk?feature=oembed', u'width': 459}, 'opengraph': { 'desc': 'SERJ TANKIAN PERFORMING HONKING ANTELOPE Ft APO(AUCKLAND PHILHARMONIA ORCHESTRA) HD QUALITY "ELECT THE DEAD SYMPHONY" DVD RIP{2010}', 'picture_url': 'http://i1.ytimg.com/vi/-r3VuOyr9lk/maxresdefault.jpg', 'title': 'Serj Tankian - Honking Antelope {Elect The Dead Symphony} (HD/DVD Quality)', 'video_height': '720', 'video_url': 'http://www.youtube.com/v/-r3VuOyr9lk?version=3&autohide=1', 'video_width': '960'}, 'twitter': { 'desc': 'SERJ TANKIAN PERFORMING HONKING ANTELOPE Ft APO(AUCKLAND PHILHARMONIA ORCHESTRA) HD QUALITY "ELECT THE DEAD SYMPHONY" DVD RIP{2010}', 'picture_url': 'http://i1.ytimg.com/vi/-r3VuOyr9lk/maxresdefault.jpg', 'title': 'Serj Tankian - Honking Antelope {Elect The Dead Symphony} (HD/DVD Quality)', 'video_height': '720', 'video_url': 'https://www.youtube.com/embed/-r3VuOyr9lk', 'video_width': '960'}}
您应该使用“global”值,它是不同后端中可用内容的副本,除非您希望为特定格式/平台提供信息。
要在代码中使用它,可以执行以下操作:
from embeder import embed data = embed.get('http://www.youtube.com/watch?v=-r3VuOyr9lk')
后端
- 默认后端检索页面的标题和描述元标记
- oembed后端检索一些oembed信息:http://oembed.com/
- opengraph后端检索一些opengraph元标记:http://ogp.me/
- twitter后端检索一些twitter元标记:https://dev.twitter.com/docs/cards/markup-reference