breadability


Namebreadability JSON
Version 0.1.20 PyPI version JSON
download
home_pagehttps://github.com/bookieio/breadability
SummaryPort of Readability HTML parser in Python
upload_time2014-04-14 02:08:22
maintainerNone
docs_urlNone
authorRick Harding
requires_pythonNone
licenseBSD
keywords bookie breadability content html parsing readability readable
VCS
bugtrack_url
requirements docopt chardet lxml pytest pytest-cov coverage pylint pep8
Travis-CI
coveralls test coverage No coveralls.
            breadability - another readability Python (v2.6-v3.3) port
===========================================================
.. image:: https://api.travis-ci.org/bookieio/breadability.png?branch=master
   :target: https://travis-ci.org/bookieio/breadability.py

I've tried to work with the various forks of some ancient codebase that ported
`readability`_ to Python. The lack of tests, unused regex's, and commented out
sections of code in other Python ports just drove me nuts.

I put forth an effort to bring in several of the better forks into one
code base, but they've diverged so much that I just can't work with it.

So what's any sane person to do? Re-port it with my own repo, add some tests,
infrastructure, and try to make this port better. OSS FTW (and yea, NIH FML,
but oh well I did try)

This is a pretty straight port of the JS here:

- http://code.google.com/p/arc90labs-readability/source/browse/trunk/js/readability.js#82
- http://www.minvolai.com/blog/decruft-arc90s-readability-in-python/


Alternatives
------------

- https://github.com/codelucas/newspaper
- https://github.com/grangier/python-goose
- https://github.com/aidanf/BTE
- http://www.unixuser.org/~euske/python/webstemmer/#extract
- https://github.com/al3xandru/readability.py
- https://github.com/rcarmo/soup-strainer
- https://github.com/bcampbell/decruft
- https://github.com/gfxmonk/python-readability
- https://github.com/srid/readability
- https://github.com/dcramer/decruft
- https://github.com/reorx/readability
- https://github.com/mote/python-readability
- https://github.com/predatell/python-readability-lxml
- https://github.com/Harshavardhana/boilerpipy
- https://github.com/raptium/hitomi
- https://github.com/kingwkb/readability


Installation
------------
This does depend on lxml so you'll need some C headers in order to install
things from pip so that it can compile.

.. code-block:: bash

    $ [sudo] apt-get install libxml2-dev libxslt-dev
    $ [sudo] pip install git+git://github.com/bookieio/breadability.git

Tests
-----
.. code-block:: bash

    $ nosetests-2.6 tests && nosetests-3.2 tests && nosetests-2.7 tests && nosetests-3.3 tests


Usage
-----
Command line
~~~~~~~~~~~~

.. code-block:: bash

    $ breadability http://wiki.python.org/moin/BeginnersGuide

Options
```````

- **b** will write out the parsed content to a temp file and open it in a
  browser for viewing.
- **d** will write out debug scoring statements to help track why a node was
  chosen as the document and why some nodes were removed from the final
  product.
- **f** will override the default behaviour of getting an html fragment (<div>)
  and give you back a full <html> document.
- **v** will output in verbose debug mode and help let you know why it parsed
  how it did.


Python API
~~~~~~~~~~
.. code-block:: python

    from __future__ import print_function

    from breadability.readable import Article


    if __name__ == "__main__":
        document = Article(html_as_text, url=source_url)
        print(document.readable)


Work to be done
---------------
Yep, I've got some catching up to do. I don't do pagination, I've got a lot of
custom tweaks I need to get going, there are some articles that fail to parse.
I also have more tests to write on a lot of the cleaning helpers, but
hopefully things are setup in a way that those can/will be added.

Fortunately, I need this library for my tools:

- https://bmark.us
- http://r.bmark.us

so I really need this to be an active and improving project.


Off the top of my heads TODO list:

- Support metadata from parsed article [url, confidence scores, all
  candidates we thought about?]
- More tests, more thorough tests
- More sample articles we need to test against in the test_articles
- Tests that run through and check for regressions of the test_articles
- Tidy'ing the HTML that comes out, might help with regression tests ^^
- Multiple page articles
- Performance tuning, we do a lot of looping and re-drop some nodes that
  should be skipped. We should have a set of regression tests for this so
  that if we implement a change that blows up performance we know it right
  away.
- More docs for things, but sphinx docs and in code comments to help
  understand wtf we're doing and why. That's the biggest hurdle to some of
  this stuff.


Inspiration
~~~~~~~~~~~

- `python-readability`_
- `decruft`_
- `readability`_



.. _readability: http://code.google.com/p/arc90labs-readability/
.. _TravisCI: http://travis-ci.org/
.. _decruft: https://github.com/dcramer/decruft
.. _python-readability: https://github.com/buriy/python-readability


.. :changelog:

Changelog for breadability
==========================

0.1.20 (April 13th 2014)
-------------------------
- Don't include tests in sdist builds.

0.1.19 (April 13th 2014)
--------------------------
- Replace charade with chardet for easier packaging.

0.1.18 (April 6th 2014)
------------------------
- Improved decoding of the page into Unicode.

0.1.17 (Jan 22nd 2014)
----------------------
- More log quieting down to INFO vs WARN

0.1.16 (Jan 22nd 2014)
----------------------
- Clean up logging output at warning when it's not a true warning

0.1.15 (Nov 29th 2013)
----------------------
- Merge changes from 0.1.14 of breadability with the fork https://github.com/miso-belica/readability.py and tweaking to return to the name breadability.
- Fork: Added property ``Article.main_text`` for getting text annotated with
  semantic HTML tags (<em>, <strong>, ...).
- Fork: Join node with 1 child of the same type. From
  ``<div><div>...</div></div>`` we get ``<div>...</div>``.
- Fork: Don't change <div> to <p> if it contains <p> elements.
- Fork: Renamed test generation helper 'readability_newtest' -> 'readability_test'.
- Fork: Renamed package to readability. (Renamed back)
- Fork: Added support for Python >= 3.2.
- Fork: Py3k compatible package 'charade' is used instead of 'chardet'.

0.1.14 (Nov 7th 2013)
---------------------
- Update sibling append to only happen when sibling doesn't already exist.

0.1.13 (Aug 31st 2013)
----------------------
- Give images in content boy a better chance of survival
- Add tests

0.1.12 (July 28th 2013)
-----------------------
- Add a user agent to requests.

0.1.11 (Dec 12th 2012)
----------------------
- Add argparse to the install requires for python < 2.7

0.1.10 (Sept 13th 2012)
-----------------------
- Updated scoring bonus and penalty with , and " characters.

0.1.9 (Aug 27nd 2012)
---------------------
- In case of an issue dealing with candidates we need to act like we didn't
  find any candidates for the article content. #10

0.1.8 (Aug 27nd 2012)
---------------------
- Add code/tests for an empty document.
- Fixes #9 to handle xml parsing issues.

0.1.7 (July 21nd 2012)
----------------------
- Change the encode 'replace' kwarg into a normal arg for older python
  version.

0.1.6 (June 17th 2012)
----------------------
- Fix the link removal, add tests and a place to process other bad links.

0.1.5 (June 16th 2012)
----------------------
- Start to look at removing bad links from content in the conditional cleaning
  state. This was really used for the scripting.com site's garbage.

0.1.4 (June 16th 2012)
----------------------
- Add a test generation helper readability_newtest script.
- Add tests and fixes for the scripting news parse failure.

0.1.3 (June 15th 2012)
----------------------
- Add actual testing of full articles for regression tests.
- Update parser to properly clean after winner doc node is chosen.

0.1.2 (May 28th 2012)
---------------------
- Bugfix: #4 issue with logic of the 100char bonus points in scoring
- Garden with PyLint/PEP8
- Add a bunch of tests to readable/scoring code.

0.1.1 (May 11th 2012)
---------------------
- Fix bugs in scoring to help in getting right content
- Add concept of -d which shows scoring/decisions on nodes
- Update command line client to be able to pipe output to other tools

0.1.0 (May 6th 2012)
--------------------
- Initial release and upload to PyPi
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/bookieio/breadability",
    "name": "breadability",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "bookie,breadability,content,HTML,parsing,readability,readable",
    "author": "Rick Harding",
    "author_email": "rharding@mitechie.com",
    "download_url": "https://files.pythonhosted.org/packages/ad/2d/bb6c9b381e6b6a432aa2ffa8f4afdb2204f1ff97cfcc0766a5b7683fec43/breadability-0.1.20.tar.gz",
    "platform": "UNKNOWN",
    "description": "breadability - another readability Python (v2.6-v3.3) port\n===========================================================\n.. image:: https://api.travis-ci.org/bookieio/breadability.png?branch=master\n   :target: https://travis-ci.org/bookieio/breadability.py\n\nI've tried to work with the various forks of some ancient codebase that ported\n`readability`_ to Python. The lack of tests, unused regex's, and commented out\nsections of code in other Python ports just drove me nuts.\n\nI put forth an effort to bring in several of the better forks into one\ncode base, but they've diverged so much that I just can't work with it.\n\nSo what's any sane person to do? Re-port it with my own repo, add some tests,\ninfrastructure, and try to make this port better. OSS FTW (and yea, NIH FML,\nbut oh well I did try)\n\nThis is a pretty straight port of the JS here:\n\n- http://code.google.com/p/arc90labs-readability/source/browse/trunk/js/readability.js#82\n- http://www.minvolai.com/blog/decruft-arc90s-readability-in-python/\n\n\nAlternatives\n------------\n\n- https://github.com/codelucas/newspaper\n- https://github.com/grangier/python-goose\n- https://github.com/aidanf/BTE\n- http://www.unixuser.org/~euske/python/webstemmer/#extract\n- https://github.com/al3xandru/readability.py\n- https://github.com/rcarmo/soup-strainer\n- https://github.com/bcampbell/decruft\n- https://github.com/gfxmonk/python-readability\n- https://github.com/srid/readability\n- https://github.com/dcramer/decruft\n- https://github.com/reorx/readability\n- https://github.com/mote/python-readability\n- https://github.com/predatell/python-readability-lxml\n- https://github.com/Harshavardhana/boilerpipy\n- https://github.com/raptium/hitomi\n- https://github.com/kingwkb/readability\n\n\nInstallation\n------------\nThis does depend on lxml so you'll need some C headers in order to install\nthings from pip so that it can compile.\n\n.. code-block:: bash\n\n    $ [sudo] apt-get install libxml2-dev libxslt-dev\n    $ [sudo] pip install git+git://github.com/bookieio/breadability.git\n\nTests\n-----\n.. code-block:: bash\n\n    $ nosetests-2.6 tests && nosetests-3.2 tests && nosetests-2.7 tests && nosetests-3.3 tests\n\n\nUsage\n-----\nCommand line\n~~~~~~~~~~~~\n\n.. code-block:: bash\n\n    $ breadability http://wiki.python.org/moin/BeginnersGuide\n\nOptions\n```````\n\n- **b** will write out the parsed content to a temp file and open it in a\n  browser for viewing.\n- **d** will write out debug scoring statements to help track why a node was\n  chosen as the document and why some nodes were removed from the final\n  product.\n- **f** will override the default behaviour of getting an html fragment (<div>)\n  and give you back a full <html> document.\n- **v** will output in verbose debug mode and help let you know why it parsed\n  how it did.\n\n\nPython API\n~~~~~~~~~~\n.. code-block:: python\n\n    from __future__ import print_function\n\n    from breadability.readable import Article\n\n\n    if __name__ == \"__main__\":\n        document = Article(html_as_text, url=source_url)\n        print(document.readable)\n\n\nWork to be done\n---------------\nYep, I've got some catching up to do. I don't do pagination, I've got a lot of\ncustom tweaks I need to get going, there are some articles that fail to parse.\nI also have more tests to write on a lot of the cleaning helpers, but\nhopefully things are setup in a way that those can/will be added.\n\nFortunately, I need this library for my tools:\n\n- https://bmark.us\n- http://r.bmark.us\n\nso I really need this to be an active and improving project.\n\n\nOff the top of my heads TODO list:\n\n- Support metadata from parsed article [url, confidence scores, all\n  candidates we thought about?]\n- More tests, more thorough tests\n- More sample articles we need to test against in the test_articles\n- Tests that run through and check for regressions of the test_articles\n- Tidy'ing the HTML that comes out, might help with regression tests ^^\n- Multiple page articles\n- Performance tuning, we do a lot of looping and re-drop some nodes that\n  should be skipped. We should have a set of regression tests for this so\n  that if we implement a change that blows up performance we know it right\n  away.\n- More docs for things, but sphinx docs and in code comments to help\n  understand wtf we're doing and why. That's the biggest hurdle to some of\n  this stuff.\n\n\nInspiration\n~~~~~~~~~~~\n\n- `python-readability`_\n- `decruft`_\n- `readability`_\n\n\n\n.. _readability: http://code.google.com/p/arc90labs-readability/\n.. _TravisCI: http://travis-ci.org/\n.. _decruft: https://github.com/dcramer/decruft\n.. _python-readability: https://github.com/buriy/python-readability\n\n\n.. :changelog:\n\nChangelog for breadability\n==========================\n\n0.1.20 (April 13th 2014)\n-------------------------\n- Don't include tests in sdist builds.\n\n0.1.19 (April 13th 2014)\n--------------------------\n- Replace charade with chardet for easier packaging.\n\n0.1.18 (April 6th 2014)\n------------------------\n- Improved decoding of the page into Unicode.\n\n0.1.17 (Jan 22nd 2014)\n----------------------\n- More log quieting down to INFO vs WARN\n\n0.1.16 (Jan 22nd 2014)\n----------------------\n- Clean up logging output at warning when it's not a true warning\n\n0.1.15 (Nov 29th 2013)\n----------------------\n- Merge changes from 0.1.14 of breadability with the fork https://github.com/miso-belica/readability.py and tweaking to return to the name breadability.\n- Fork: Added property ``Article.main_text`` for getting text annotated with\n  semantic HTML tags (<em>, <strong>, ...).\n- Fork: Join node with 1 child of the same type. From\n  ``<div><div>...</div></div>`` we get ``<div>...</div>``.\n- Fork: Don't change <div> to <p> if it contains <p> elements.\n- Fork: Renamed test generation helper 'readability_newtest' -> 'readability_test'.\n- Fork: Renamed package to readability. (Renamed back)\n- Fork: Added support for Python >= 3.2.\n- Fork: Py3k compatible package 'charade' is used instead of 'chardet'.\n\n0.1.14 (Nov 7th 2013)\n---------------------\n- Update sibling append to only happen when sibling doesn't already exist.\n\n0.1.13 (Aug 31st 2013)\n----------------------\n- Give images in content boy a better chance of survival\n- Add tests\n\n0.1.12 (July 28th 2013)\n-----------------------\n- Add a user agent to requests.\n\n0.1.11 (Dec 12th 2012)\n----------------------\n- Add argparse to the install requires for python < 2.7\n\n0.1.10 (Sept 13th 2012)\n-----------------------\n- Updated scoring bonus and penalty with , and \" characters.\n\n0.1.9 (Aug 27nd 2012)\n---------------------\n- In case of an issue dealing with candidates we need to act like we didn't\n  find any candidates for the article content. #10\n\n0.1.8 (Aug 27nd 2012)\n---------------------\n- Add code/tests for an empty document.\n- Fixes #9 to handle xml parsing issues.\n\n0.1.7 (July 21nd 2012)\n----------------------\n- Change the encode 'replace' kwarg into a normal arg for older python\n  version.\n\n0.1.6 (June 17th 2012)\n----------------------\n- Fix the link removal, add tests and a place to process other bad links.\n\n0.1.5 (June 16th 2012)\n----------------------\n- Start to look at removing bad links from content in the conditional cleaning\n  state. This was really used for the scripting.com site's garbage.\n\n0.1.4 (June 16th 2012)\n----------------------\n- Add a test generation helper readability_newtest script.\n- Add tests and fixes for the scripting news parse failure.\n\n0.1.3 (June 15th 2012)\n----------------------\n- Add actual testing of full articles for regression tests.\n- Update parser to properly clean after winner doc node is chosen.\n\n0.1.2 (May 28th 2012)\n---------------------\n- Bugfix: #4 issue with logic of the 100char bonus points in scoring\n- Garden with PyLint/PEP8\n- Add a bunch of tests to readable/scoring code.\n\n0.1.1 (May 11th 2012)\n---------------------\n- Fix bugs in scoring to help in getting right content\n- Add concept of -d which shows scoring/decisions on nodes\n- Update command line client to be able to pipe output to other tools\n\n0.1.0 (May 6th 2012)\n--------------------\n- Initial release and upload to PyPi",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Port of Readability HTML parser in Python",
    "version": "0.1.20",
    "project_urls": {
        "Download": "UNKNOWN",
        "Homepage": "https://github.com/bookieio/breadability"
    },
    "split_keywords": [
        "bookie",
        "breadability",
        "content",
        "html",
        "parsing",
        "readability",
        "readable"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ad2dbb6c9b381e6b6a432aa2ffa8f4afdb2204f1ff97cfcc0766a5b7683fec43",
                "md5": "57903360c77f4603d634511566ef1595",
                "sha256": "f1a7fdad1e58e295df80954879143824c706bbfb1826cdf4b1d15de1a86afe99"
            },
            "downloads": -1,
            "filename": "breadability-0.1.20.tar.gz",
            "has_sig": false,
            "md5_digest": "57903360c77f4603d634511566ef1595",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 32505,
            "upload_time": "2014-04-14T02:08:22",
            "upload_time_iso_8601": "2014-04-14T02:08:22.862832Z",
            "url": "https://files.pythonhosted.org/packages/ad/2d/bb6c9b381e6b6a432aa2ffa8f4afdb2204f1ff97cfcc0766a5b7683fec43/breadability-0.1.20.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2014-04-14 02:08:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bookieio",
    "github_project": "breadability",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "docopt",
            "specs": [
                [
                    ">=",
                    "0.6.1"
                ],
                [
                    "<",
                    "0.7"
                ]
            ]
        },
        {
            "name": "chardet",
            "specs": []
        },
        {
            "name": "lxml",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "pytest-cov",
            "specs": []
        },
        {
            "name": "coverage",
            "specs": []
        },
        {
            "name": "pylint",
            "specs": []
        },
        {
            "name": "pep8",
            "specs": []
        }
    ],
    "tox": true,
    "lcname": "breadability"
}
        
Elapsed time: 0.35950s