Skip to content

bear/mf2py

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mf2py

A new Python parser for microformats 2.

Current status: early alpha - mostly usable. Implements property parsing (except value-class-pattern rules), implied and rels/alternate parsing.

Tom Morris: Please do help work on it. Currently I'm just writing test cases as we implement stuff and TDDing to completion. Once the parser is stable, I intend to import one of the full test suites.

Will eventually need good documentation and tidying up.

License: MIT

Install

pip install mf2py

Kartik Prabhu: 'this version not on pip'

Usage

Import the parser object using

from mf2py.parser import Parser

Parse a file containing the content

file = open('file/content.html','r')
p = Parser(doc=file)
file.close()

Parse string containing content

content = '<article class="h-entry"><h1 class="p-name">Hellow</h1></article>'
p = Parser(doc=content)

Parse content from a URL

p = Parser(url="http://tommorris.org/")

Get parsed microformat as python dictionary

p.to_dict()

Get parsed microformat as JSON output

p.to_json()

Filter by microformat type

p.to_dict(filter_by_type="h-entry")
p.to_json(filter_by_type="h-entry")

About

mf2 parser in python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%