分析开放图协议并提取网页摘要的模块。
ExtendedOpenGraph的Python项目详细描述
extendedOpenGraphParser是一个用于解析OpenGraph协议的Python模块。
开放图形协议规范:http://ogp.me/
安装
pip install extendedOpenGraph
功能
- 基于opengraph。
- 如果在元标签中不存在打开的图形属性,则能够解析基本元数据。
- 输入url和html。
- 输出python字典。
- 比如Facebook。
用法
input:url
>>> import ExtendedOpenGraph >>> data = ExtendedOpenGraph.parse(url="http://www.twitter.com") >>> for key, value in data.items(): ... print "%-15s => %s" % (key, value) ... url => http://www.twitter.com image => https://abs.twimg.com/a/1373572090/t1/img/front_page/jp-mountain@2x.jpg type => website title => 트위터
input:html
>>> ex_html="<html><head><title>ExtendOpenGraph</title></head><body><img src='logo.png'/></body></html>" >>> data = ExtendedOpenGraph.parse(html=ex_html) >>> for key, value in data.items(): ... print "%-15s => %s" % (key, value) ... url => None image => logo.png type => website title => ExtendOpenGraph