一个用于从URL中提取丰富内容的库
项目描述
一个用于从URL中提取丰富内容的库。
它做什么?
micawber提供了一些方法来检索关于各种链接的丰富元数据,例如YouTube视频链接。micawber还提供了解析文本和HTML块的功能,并用丰富的嵌入内容替换视频链接。
示例
这是一个快速示例
import micawber
# load up rules for some default providers, such as youtube and flickr
providers = micawber.bootstrap_basic()
providers.request('http://www.youtube.com/watch?v=54XHDUOHuzU')
# returns the following dictionary:
{
'author_name': 'pascalbrax',
'author_url': u'http://www.youtube.com/user/pascalbrax'
'height': 344,
'html': u'<iframe width="459" height="344" src="http://www.youtube.com/embed/54XHDUOHuzU?fs=1&feature=oembed" frameborder="0" allowfullscreen></iframe>',
'provider_name': 'YouTube',
'provider_url': 'http://www.youtube.com/',
'title': 'Future Crew - Second Reality demo - HD',
'type': u'video',
'thumbnail_height': 360,
'thumbnail_url': u'http://i2.ytimg.com/vi/54XHDUOHuzU/hqdefault.jpg',
'thumbnail_width': 480,
'url': 'http://www.youtube.com/watch?v=54XHDUOHuzU',
'width': 459,
'version': '1.0',
}
providers.parse_text('this is a test:\nhttp://www.youtube.com/watch?v=54XHDUOHuzU')
# returns the following string:
this is a test:
<iframe width="459" height="344" src="http://www.youtube.com/embed/54XHDUOHuzU?fs=1&feature=oembed" frameborder="0" allowfullscreen></iframe>
providers.parse_html('<p>http://www.youtube.com/watch?v=54XHDUOHuzU</p>')
# returns the following html:
<p><iframe width="459" height="344" src="http://www.youtube.com/embed/54XHDUOHuzU?fs=1&feature=oembed" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
项目详情
关闭
micawber-0.5.5.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0ac5814b65ff2a781fb1394b91a23a8a95f73492b6bb8f705baeead82eadd543 |
|
MD5 | 801b87ce0bb87026d761e8b0eebc6116 |
|
BLAKE2b-256 | ab19d72a97f879f6635ca61e699ff0104a62b8be1d46cc21bd904d07a338b6bf |