Heuristic based boilerplate removal tool
Program jusText is a tool for removing boilerplate content, such as navigation links, headers, and footers from HTML pages. It is designed to preserve mainly text containing full sentences and it is therefore well suited for creating linguistic resources such as Web corpora. You can try it online.
This is a fork of original (currently unmaintained) code of jusText hosted on Google Code. Below are some alternatives that I found:
$ [sudo] pip install justext
$ python -m justext -s Czech -o text.txt http://www.zdrojak.cz/clanky/automaticke-zabezpeceni/ $ python -m justext -s English -o plain_text.txt english_page.html $ python -m justext --help # for more info
import requests import justext response = requests.get("http://planet.python.org/") paragraphs = justext.justext(response.content, justext.get_stoplist("English")) for paragraph in paragraphs: if not paragraph.is_boilerplate: print paragraph.text
Run tests via
$ py.test-2.6 && py.test-3.3 && py.test-2.7 && py.test-3.4 && py.test-3.5
Changelog for jusText
- INCOMPATIBLE CHANGE: Stop words are case insensitive.
- INCOMPATIBLE CHANGE: Dropped support for Python 3.2
- BUG FIX: Preserve new lines from original text in paragraphs.
- BUG FIX: Function decode_html now respects parameter errors when falling to default_encoding #9.
- FEATURE: Added XPath selector to the paragrahs. XPath selector is also available in detailed output as xpath attribute of <p> tag #5.
- FEATURE: Added pluggable DOM preprocessor.
- FEATURE: Added support for Python 3.2+.
- INCOMPATIBLE CHANGE: Paragraphs are instances of justext.paragraph.Paragraph.
- INCOMPATIBLE CHANGE: Script ‘justext’ removed in favour of command python -m justext.
- FEATURE: It’s possible to enter an URI as input document in CLI.
- FEATURE: It is possible to pass unicode string directly.
- FEATURE: Character counts used instead of word counts where possible in order to make the algorithm work well in the language independent mode (without a stoplist) for languages where counting words is not easy (Japanese, Chinese, Thai, etc).
- BUG FIX: More robust parsing of meta tags containing the information about used charset.
- BUG FIX: Corrected decoding of HTML entities € to Ÿ
- First public release.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|jusText-2.2.0-py2.py3-none-any.whl (860.8 kB) Copy SHA256 Checksum SHA256||py2.py3||Wheel||Mar 6, 2016|
|jusText-2.2.0.zip (864.1 kB) Copy SHA256 Checksum SHA256||–||Source||Mar 6, 2016|