{ "info": { "author": "Steve @siznax", "author_email": "steve@siznax.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3" ], "description": "frag2text\n=========\n\n.. image:: https://img.shields.io/pypi/v/frag2text.svg\n :target: https://pypi.python.org/pypi/frag2text/\n\nMarkdown_ gives you HTML from plain text and html2text_ reverses the\nprocess. If you want the plain text version of *a specific section* of\na web page (an HTML fragment), you would normally do the selecting\n(parsing) first, then generate the Markdown text to preserve some\nformatting.\n\nI made *frag2text* to:\n\n* easily select a web page fragment by CSS selector or XPath\n expression\n* get the plain text of the fragment with some formatting intact for\n later use with Markdown\n* not shell out to a another program (like lynx -dump)\n* not parse HTML or text directly\n* use html5lib for robust parsing\n* have a simple python module that is easy to maintain (encapsulating\n the tricky business of subclassing parsers, treebuilders and\n serializers, by keeping it simple \u2013 this shouldn't require\n BeautifulSoup) \n\nThis is a problem I've tinkered with for some time and solved in many\ndifferent ways. It seems trivial but gets ridiculous quickly. If you\nhave any suggestions or want to share your experiences with other\ntools, please let me know.\n\n\nInstall\n=======\n\n.. code-block:: shell\n\n $ pip install frag2text\n\n\nUsage\n=====\n\npython\n------\n\n.. code-block:: python\n\n >>> from frag2text import frag2text\n >>> help(frag2text)\n Help on function frag2text in module frag2text:\n\n frag2text(endpoint, stype, selector, clean=False, raw=False, verbose=False)\n returns Markdown text of selected fragment.\n\n Args:\n endpoint: URL, file, or HTML string\n stype: { 'css' | 'xpath' }\n selector: CSS selector or XPath expression\n Returns:\n Markdown text\n Options:\n clean: cleans fragment (lxml.html.clean defaults)\n raw: returns raw HTML fragment\n verbose: show http status, encoding, headers\n\nshell\n-----\n\n.. code-block:: shell\n\n $ frag2text.py -h\n usage: frag2text.py [-h] [-c] [-r] [-v] endpoint {css,xpath} selector\n\n reverse Markdown (html2text) HTML fragments.\n\n positional arguments:\n endpoint URL, file, or HTML string\n {css,xpath} fragment selector type\n selector CSS select statement or XPath expression\n\n optional arguments:\n -h, --help show this help message and exit\n -c, --clean clean fragment (lxml.html.clean defaults)\n -r, --raw output raw fragment\n -v, --verbose print status, encoding, headers\n\n\nExamples\n========\n\npython\n------\n\n.. code-block:: python\n\n from frag2text import frag2text\n\n info = frag2text('http://wikipedia.org/wiki/Amanita', 'css', '.infobox')\n\n\nshell\n-----\n\n.. code-block:: shell\n\n $ frag2text.py \"

hello\" xpath //h1\n ...\n # hello\n\n\nCSS select\n----------\n\n.. code-block:: shell\n\n $ frag2text.py http://wikipedia.org/wiki/Amanita css .infobox\n _Amanita_\n ---\n ![Fliegenpilz-1.jpg](//upload.wikimedia.org/wikipedia/commons/thumb/d/d1\n /Fliegenpilz-1.jpg/230px-Fliegenpilz-1.jpg)\n _[Amanita muscaria](/wiki/Amanita_muscaria)_\n Albin Schmalfu\u00df, 1897\n [Scientific classification](/wiki/Biological_classification)\n Kingdom: | [Fungi](/wiki/Fungi)\n Division: | [Basidiomycota](/wiki/Basidiomycota)\n Class: | [Agaricomycetes](/wiki/Agaricomycetes)\n Order: | [Agaricales](/wiki/Agaricales)\n Family: | [Amanitaceae](/wiki/Amanitaceae)\n Genus: | _**Amanita**_\n [Pers.](/wiki/Christian_Hendrik_Persoon) (1794)\n [Type species](/wiki/Type_species)\n _[Amanita muscaria](/wiki/Amanita_muscaria)_\n ([L.](/wiki/Linnaeus)) [Lam.](/wiki/Lam.) (1783)\n [Diversity](/wiki/Biodiversity)\n [c.600 species](/wiki/List_of_Amanita_species)\n\n\nXPath expression\n----------------\n\n.. code-block:: shell\n\n $ frag2text.py http://en.wikipedia.org/wiki/Amanita xpath '//p[1]'\n\n The [genus](/wiki/Genus) _**Amanita**_ contains about 600 [species](/wik\n i/Species) of [agarics](/wiki/Agarics) including some of the most [toxic\n ](/wiki/Toxic) known [mushrooms](/wiki/Mushrooms) found worldwide, as we\n ll as some well-regarded edible species. This genus is responsible for a\n pproximately 95% of the fatalities resulting from [mushroom poisoning](/\n wiki/Mushroom_poisoning), with the [death cap](/wiki/Death_cap) accounti\n ng for about 50% on its own. The most potent toxin present in these mush\n rooms is \u03b1[-amanitin](/wiki/%CE%91-amanitin).\n\n\n.. _Markdown: https://github.com/waylan/Python-Markdown\n.. _html2text: https://github.com/Alir3z4/html2text/\n\n\n.. :changelog:\n\nRelease History\n---------------\n\n0.0.5 (2015-02-18)\n++++++++++++++++++\n\n* handle XPathEvalError, SelectorSyntaxError and Nothing found.\n* join list of selected fragments, was only returning first.\n* do not exit early on error.\n\n0.0.1 (2015-01-14)\n++++++++++++++++++\n\n* It seems to work!", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/siznax/frag2text/", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "frag2text", "package_url": "https://pypi.org/project/frag2text/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/frag2text/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/siznax/frag2text/" }, "release_url": "https://pypi.org/project/frag2text/0.0.6/", "requires_dist": null, "requires_python": null, "summary": "Select and reverse-Markdown (html2text) web page fragments.", "version": "0.0.6" }, "last_serial": 2247956, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "860f476d4619de0bcc1b92acbb7cbe62", "sha256": "c9ca17249a4b00cb5e58df996e122e5bdc6c2e9bd442e3fc0e7b53446b1b6ceb" }, "downloads": -1, "filename": "frag2text-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "860f476d4619de0bcc1b92acbb7cbe62", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 7443, "upload_time": "2015-01-17T00:24:57", "url": "https://files.pythonhosted.org/packages/91/d3/697705ae0303bb8b7ca6476494e97e020c368e41d2058996caf97ca804dc/frag2text-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "913ec71850aa2e9771245fb8781bd58d", "sha256": "1d110634ae10c3fcb8f56b74759177cc3911dfc69eee3f216c3f79733182493a" }, "downloads": -1, "filename": "frag2text-0.0.1.tar.gz", "has_sig": false, "md5_digest": "913ec71850aa2e9771245fb8781bd58d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6014, "upload_time": "2015-01-17T00:24:40", "url": "https://files.pythonhosted.org/packages/76/27/6040ff205737c5e9af76f471a71b6b2dc7ab1c85b359391555dec0037861/frag2text-0.0.1.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "979b98960eeb5ce90b58686e30941673", "sha256": "8338af5b147d34ffc4b6be31b74fbdd0e3c4ebf63f99bb7c99e41be5a30cd81f" }, "downloads": -1, "filename": "frag2text-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "979b98960eeb5ce90b58686e30941673", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 7984, "upload_time": "2015-02-18T23:45:26", "url": "https://files.pythonhosted.org/packages/f4/63/c8a0f8d2e60a167bd4a9474d17baef664d6dfa73a8ce92877178dde0671c/frag2text-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5aed1c286bc22b30a5c36db67ff974ae", "sha256": "c5ee2187cd2afd76d5cbcef0e7b8269e8ac4ccfa42d3f7372a886967fce68179" }, "downloads": -1, "filename": "frag2text-0.0.5.tar.gz", "has_sig": false, "md5_digest": "5aed1c286bc22b30a5c36db67ff974ae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5936, "upload_time": "2015-02-18T23:45:12", "url": "https://files.pythonhosted.org/packages/f1/26/18d793bb42f5e4ffe790433873593389b0776b7a5c117a2cfc60db232096/frag2text-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "61a0d8e060b91dceade455a032798d44", "sha256": "b4daa48bff6b330936770b989d1097613bb5474df382f28fa1a8819e745bf3db" }, "downloads": -1, "filename": "frag2text-0.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "61a0d8e060b91dceade455a032798d44", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 7981, "upload_time": "2016-07-28T00:15:24", "url": "https://files.pythonhosted.org/packages/30/98/59afb67a88780104af7e89852eed8e9f46be39f641e35f492670a0ae5e49/frag2text-0.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "77c7188590e8787756dd9c42714c3d7d", "sha256": "04d8d112d1d91bc8ebd3ed2c370691c3c00e7806d973c24a23ae543cb7c4a4e1" }, "downloads": -1, "filename": "frag2text-0.0.6.tar.gz", "has_sig": false, "md5_digest": "77c7188590e8787756dd9c42714c3d7d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5942, "upload_time": "2016-07-28T00:14:59", "url": "https://files.pythonhosted.org/packages/b8/7e/c5b43da730280f131c15ef2933dac64628970bcd14702f7af2f91239d520/frag2text-0.0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "61a0d8e060b91dceade455a032798d44", "sha256": "b4daa48bff6b330936770b989d1097613bb5474df382f28fa1a8819e745bf3db" }, "downloads": -1, "filename": "frag2text-0.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "61a0d8e060b91dceade455a032798d44", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 7981, "upload_time": "2016-07-28T00:15:24", "url": "https://files.pythonhosted.org/packages/30/98/59afb67a88780104af7e89852eed8e9f46be39f641e35f492670a0ae5e49/frag2text-0.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "77c7188590e8787756dd9c42714c3d7d", "sha256": "04d8d112d1d91bc8ebd3ed2c370691c3c00e7806d973c24a23ae543cb7c4a4e1" }, "downloads": -1, "filename": "frag2text-0.0.6.tar.gz", "has_sig": false, "md5_digest": "77c7188590e8787756dd9c42714c3d7d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5942, "upload_time": "2016-07-28T00:14:59", "url": "https://files.pythonhosted.org/packages/b8/7e/c5b43da730280f131c15ef2933dac64628970bcd14702f7af2f91239d520/frag2text-0.0.6.tar.gz" } ] }