跳转到主要内容

从微格式中解析hentry。

项目描述

解析具有微格式标记的精美网页。如果您对微格式一无所知,请查看 http://microformats.org/wiki/hentry

hentry模式看起来像

<article class="hentry">
    <h1 class="entry-title">Article title</h1>
    <time class="updated" datetime="2014-11-06T20:00:00Z" pubdate>2014-11-06</time>
    <div class="entry-content">
        <p>Here is the content</p>
    </div>
    <div class="entry-tags">
        <a href="#tag1" rel="tag">tag1</a>
        <a href="#tag2" rel="tag">tag2</a>
    </div>
    <div class="vcard author">
        <span class="fn">Author Name</span>
    </div>
</article>

使用这个库 hentry.py,您可以解析html到元数据

hentry.parse_html(text, format='html')

安装

使用pip安装hentry

$ pip install hentry

基本用法

通过URL解析网页

hentry.parse_url(url)

通过html内容解析网页

hentry.parse_html(content)

结果是包含以下内容的字典

  1. 标题

  2. 内容

  3. 作者

  4. 发布日期

  5. 标签

  6. 分类

  7. 图片

项目详情


版本历史 发布通知 | RSS源

下载文件

下载适用于您的平台的文件。如果您不确定要选择哪个,请了解更多关于 安装软件包 的信息。

源分发

hentry-0.1.tar.gz (3.5 kB 查看哈希)

上传时间:

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面