{ "info": { "author": "Kyungil Choi", "author_email": "hanpama@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Internet :: WWW/HTTP" ], "description": "Peppertext\n==========\n\nDeclarative hypertext client\n\n\nInstallation\n------------\n\n.. code-block:: bash\n\n pip install peppertext\n\n\nOverview\n--------\n\n\n.. code-block:: python\n\n from peppertext import Hypertext, SimpleURLField, resolve, register, selector\n\n @register\n class GoogleBlogPage(Hypertext):\n url = SimpleURLField(\n \"https://googleblog.blogspot.kr/{year}/{month}/{title}.html\"\n )\n\n title = selector.find(\".title[itemprop=name]\").text()\n body = selector.find(\".post-body\").text()\n\n\nIt resolves given headers, url and query string to hypertext object.\n\n.. code-block:: python\n\n >>> p = resolve(\"https://googleblog.blogspot.kr/2015/11/google-gobble-thanksgiving-trends-on.html\")\n >>> p\n \n\n >>> p.fetch()\n >>> p['title']\n 'Google gobble: Thanksgiving trends on Search'\n >>> p['body']\n 'In just a few hours, people across the U.S. will be settling...'\n\nYou can create GoogleBlogPage object with profile variables which are declared as\nfields in `GoogleBlogPage` class.\n\n\n.. code-block:: python\n\n >>> p = GoogleBlogPage(\n ... year=\"2015\",\n ... month=\"11\",\n ... title=\"google-gobble-thanksgiving-trends-on\"\n ... )\n\n >>> p.fetch()\n >>> p['title']\n 'Google gobble: Thanksgiving trends on Search'\n\n\nSelectors\n---------\n\n.. code-block:: python\n\n class GoogleBlogPage(Hypertext):\n # ...\n title = selector.find(\".title[itemprop=name]\").text()\n # ...\n\nSelectors process a document which is returned from server as response.\nIn the `GoogleBlogPage` example above, `title` selector parses document and\nfind an element specified with `\".title[itemprop=name]\"` css selector.\nYou can access the value title with subscribing the `GoogleBlogPage` object\nwith selector name.\n\n.. code-block:: python\n\n document = pq(\"\"\"
\n Link1\n Link2\n Link3\n
\"\"\")\n\n find_selector = selector.find('a')\n selected_els = find_selector.select(document)\n self.assertEqual( [pq(el).attr[\"href\"] for el in selected_els],\n [\n \"http://example.com\",\n \"http://example.com/dahokan\",\n \"http://example.com/manoha\"\n ]\n )\n\n\n`find`\n\"\"\"\"\"\"\n\nSelect html elements which match to given css selector string.\n\n`attribute`\n\"\"\"\"\"\"\"\"\"\"\"\n\nGet an element's attribute value with given attribute name.\n\n`text`\n\"\"\"\"\"\"\n\nSelect the html element's inner text value.\n\n`at`\n\"\"\"\"\n\nGet an item on index\n\n`sub`\n\"\"\"\"\"\n\n.. code-block:: python\n\n sub_selector = selector.sub(pattern=\"\\d+\", repl=\"\")\n\nDo regex substitution.\n\n`cast`\n\"\"\"\"\"\"\n\n.. code-block:: python\n\n int_cast_selector = selector.cast(int)\n\nPass the data to the function given as a parameter.\n\n\nCompatibility\n-------------\n\nPeppertext supports Python 2.7 and 3.\n\n\nFeatures in developing\n----------------------\n\n* Interface for parse error handling\n* Polymorphic access to page selectors\n* Interface to resolve and traverse links in a page", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hanpama/peppertext", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "Peppertext", "package_url": "https://pypi.org/project/Peppertext/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/Peppertext/", "project_urls": { "Homepage": "https://github.com/hanpama/peppertext" }, "release_url": "https://pypi.org/project/Peppertext/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "Declarative hypertext client", "version": "0.1.3" }, "last_serial": 1955461, "releases": { "0.1.1": [], "0.1.2": [ { "comment_text": "", "digests": { "md5": "59fe22e5a2232685a95a14902b6d54bf", "sha256": "3ffe9a2f727ded994cbdd92573a32c56d9c7f11114a24d8ac0daa5cae8ccee7e" }, "downloads": -1, "filename": "peppertext-0.1.2.tar.gz", "has_sig": false, "md5_digest": "59fe22e5a2232685a95a14902b6d54bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7592, "upload_time": "2015-12-13T12:50:34", "url": "https://files.pythonhosted.org/packages/bd/1c/aa500a9d77261a845162d0935aae2bd04ca9130c5b3576021a796c630032/peppertext-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "4f5a27c5f8524f0e6fec9680a191f2b6", "sha256": "e5361a56694f8de9769df15020386d6beada1181a8cec6a05b16651bd00faf82" }, "downloads": -1, "filename": "peppertext-0.1.3.tar.gz", "has_sig": false, "md5_digest": "4f5a27c5f8524f0e6fec9680a191f2b6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7767, "upload_time": "2016-02-14T11:49:23", "url": "https://files.pythonhosted.org/packages/3f/df/ad332f43257427a819576c844e233d5dbf244491cfd06e065d878ac57943/peppertext-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4f5a27c5f8524f0e6fec9680a191f2b6", "sha256": "e5361a56694f8de9769df15020386d6beada1181a8cec6a05b16651bd00faf82" }, "downloads": -1, "filename": "peppertext-0.1.3.tar.gz", "has_sig": false, "md5_digest": "4f5a27c5f8524f0e6fec9680a191f2b6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7767, "upload_time": "2016-02-14T11:49:23", "url": "https://files.pythonhosted.org/packages/3f/df/ad332f43257427a819576c844e233d5dbf244491cfd06e065d878ac57943/peppertext-0.1.3.tar.gz" } ] }