项目
在 GitHub 查看
coleifer/micawber
关于
用于从 URL 中提取富内容的小型库
开发工具实测星标增长
- 24小时
- 0
- 7天
- +1
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文.. image:: http://media.charlesleifer.com/blog/photos/micawber-logo-0.png
A small library for extracting rich content from urls.
what does it do?
micawber supplies a few methods for retrieving rich metadata about a variety of links, such as links to youtube videos. micawber also provides functions for parsing blocks of text and html and replacing links to videos with rich embedded content.
examples
here is a quick example:
.. code-block:: python
import micawber
# load up rules for some default providers, such as youtube and flickr
providers = micawber.bootstrap_basic()
providers.request('https://www.youtube.com/watch?v=54XHDUOHuzU', maxwidth=640)
# returns the following dictionary:
{
'author_name': 'Pascal Brax',
'author_url': 'https://www.youtube.com/@PascalBrax',
'height': 480,
'html': '<iframe width="640" height="480" src="https://www.youtube.com/embed/54XHDUOHuzU?feature=oembed" ...></iframe>',
'provider_name': 'YouTube',
'provider_url': 'https://www.youtube.com/',
'thumbnail_height': 360,
'thumbnail_url': 'https://i.ytimg.com/vi/54XHDUOHuzU/hqdefault.jpg',
'thumbnail_width': 480,
'title': 'Future Crew - Second Reality demo - HD',
'type': 'video',
'url': 'https://www.youtube.com/watch?v=54XHDUOHuzU',
'version': '1.0',
'width': 640,
}
providers.parse_text('this is a test:\nhttps://www.youtube.com/watch?v=54XHDUOHuzU')
# returns the following string:
this is a test:
<iframe width="200" height="150" src="https://www.youtube.com/embed/54XHDUOHuzU?feature=oembed" ...></iframe>
providers.parse_html('<p>https://www.youtube.com/watch?v=54XHDUOHuzU</p>')
# returns the following html:
<p><iframe width="200" height="150" src="https://www.youtube.com/embed/54XHDUOHuzU?feature=oembed" ...></iframe></p>
探索相关项目
加载中…