2010-04-22 11:55:00 +00:00
|
|
|
This code is under the Apache License 2.0. http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
This is a python port of a ruby port of arc90's readability project
|
|
|
|
|
|
|
|
http://lab.arc90.com/experiments/readability/
|
|
|
|
|
2011-05-03 04:45:23 +00:00
|
|
|
In few words,
|
2010-04-22 11:55:00 +00:00
|
|
|
Given a html document, it pulls out the main body text and cleans it up.
|
2011-05-03 04:45:23 +00:00
|
|
|
It also can clean up title based on latest readability.js code.
|
2010-04-22 11:55:00 +00:00
|
|
|
|
2011-05-03 04:45:23 +00:00
|
|
|
Based on:
|
|
|
|
- Latest readability.js ( https://github.com/MHordecki/readability-redux/blob/master/readability/readability.js )
|
|
|
|
- Ruby port by starrhorne and iterationlabs
|
|
|
|
- Python port by gfxmonk ( https://github.com/gfxmonk/python-readability , based on BeautifulSoup )
|
|
|
|
- Decruft effort to move to lxml ( http://www.minvolai.com/blog/decruft-arc90s-readability-in-python/ )
|
2011-06-30 05:08:46 +00:00
|
|
|
- "BR to P" fix from readability.js which improves quality for smaller texts.
|
|
|
|
- Github users contributions.
|
2011-06-14 11:33:15 +00:00
|
|
|
|
2011-07-26 06:40:53 +00:00
|
|
|
Installation::
|
|
|
|
|
2011-07-26 18:56:17 +00:00
|
|
|
easy_install readability-lxml
|
2011-07-26 06:40:53 +00:00
|
|
|
or
|
2011-07-26 18:56:17 +00:00
|
|
|
pip install readability-lxml
|
2011-07-26 06:40:53 +00:00
|
|
|
|
2011-07-01 17:24:15 +00:00
|
|
|
Usage::
|
2011-06-14 11:33:15 +00:00
|
|
|
|
2011-07-01 17:24:15 +00:00
|
|
|
from readability.readability import Document
|
|
|
|
import urllib
|
|
|
|
html = urllib.urlopen(url).read()
|
|
|
|
readable_article = Document(html).summary()
|
|
|
|
readable_title = Document(html).short_title()
|
2011-06-30 04:47:14 +00:00
|
|
|
|
2011-07-01 17:24:15 +00:00
|
|
|
Command-line usage::
|
2011-06-30 04:47:14 +00:00
|
|
|
|
2011-07-01 17:24:15 +00:00
|
|
|
python -m readability.readability -u http://pypi.python.org/pypi/readability-lxml
|
2012-04-17 00:55:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
Document() kwarg options:
|
|
|
|
|
2012-04-17 01:24:33 +00:00
|
|
|
- attributes:
|
|
|
|
- debug: output debug messages
|
|
|
|
- min_text_length:
|
|
|
|
- retry_length:
|
|
|
|
- url: will allow adjusting links to be absolute
|
2012-04-17 17:40:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
Updates
|
|
|
|
|
|
|
|
- 0.2.5 Update setup.py for uploading .tar.gz to pypi
|
|
|
|
|