{ "info": { "author": "Alex Sieusahai", "author_email": "alexsieu14@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# Librarian\n\nThe goal of this package is to almost be like a training wheels setup for web scraping.\n\nA good example is recursively trying to visit all of the links on a site such as:\n\nhttp://web.archive.org/web/20080827084856/http://www.nanowerk.com:80/nanotechnology/nanomaterial/commercial_all.php?page=2\n\nIf you mess up your scrape and you have done no preemptive measures, you lose all of your work done thus far. What `Librarian` aims to do is to save that html for later, so you don't have to redo scrapes that you have done before, letting you be much nicer to where you're requesting to and saving you time, letting you go through a much smoother scraping experience.\n\nLet's outline an example:\n\nTake a look at the site above's html via Inspect Element; You will see that all of the names and links are under
, and all of the blurbs are under
. Now, I would probably do this:\n\n```python3\nfrom urllib.request import urlopen\nfrom bs4 import BeautifulSoup\n\nalink = 'http://web.archive.org/web/20080827084856/http://www.nanowerk.com:80/nanotechnology/nanomaterial/commercial_all.php?page=2'\nresp = urlopen(alink)\nhtml = resp.read()\nsoup = BeautifulSoup(html, 'lxml')\n\nfor elem in soup.select('div.divhead'):\n print(elem.get_text())\n```\n\nTo check if I was correct and there was nothing above that had the same css selector, to see if I had to change my headers using urllib.request.Request, or something else.\nThen I'd probably check the same for `div.divline`, for the first reason above. Then for each of those sites, I'd have to recursively visit into them and grab their html.\n\nIf I screw anything up, or if some pages have different html, then it will take a long time to get back to where I was, making the process of scraping a site more painful than it has to be.\n\nIf we use `Librarian`, we can instead do this:\n\n```python3\nfrom librarian import Librarian\n\nlib = Librarian()\n\nalink = 'http://web.archive.org/web/20080827084856/http://www.nanowerk.com:80/nanotechnology/nanomaterial/commercial_all.php?page=2'\n\nhtml = lib.get(alink)\nsoup = BeautifulSoup(html, 'lxml')\n```\n\nNow, if I ever ask for that same website again (provided that `htmlLibrary` and the pickled files under `libarianTools` haven't been tampered with), the `Librarian` will find it and pull it out of your `htmlLibrary` so you can instantly use it.\n\nIf you need updated html, just\n\n```python3\nfrom librarian import Librarian\n\nalink = 'http://web.archive.org/web/20080827084856/http://www.nanowerk.com:80/nanotechnology/nanomaterial/commercial_all.php?page=2'\n\nremoved = lib.remove(alink)\nassert removed\n```\n\n`lib.remove(alink)` will remove the link `alink` from your `htmlLibrary` and `linkMap`, so if you ever call `lib.get(alink)` with the same link, the `Librarian` will get the html once again.\n\n\nThis project is in it's infancy so if you want any features created, create an issue and I will get on it.\n\n\nThank you to `keithreitz` for creating `samplemod`, which I largely copied for the project structure.\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/alexsieusahai/Librarian", "keywords": "", "license": "Copyright 2018 Alex Sieusahai\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", "maintainer": "", "maintainer_email": "", "name": "html_librarian", "package_url": "https://pypi.org/project/html_librarian/", "platform": "", "project_url": "https://pypi.org/project/html_librarian/", "project_urls": { "Homepage": "https://github.com/alexsieusahai/Librarian" }, "release_url": "https://pypi.org/project/html_librarian/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Never ever scrape the html off of a site multiple times ever again.", "version": "0.0.1" }, "last_serial": 3998196, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "13a5428461f5ef0c1f8373fe8e5ef60b", "sha256": "e6a3b2a522cd01e613e1e5ed6aa59803772c645fd1711d56bf1c39d389379eda" }, "downloads": -1, "filename": "html_librarian-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "13a5428461f5ef0c1f8373fe8e5ef60b", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 7930, "upload_time": "2018-06-25T03:10:54", "url": "https://files.pythonhosted.org/packages/62/e8/95e1e26f806bf10f132697cbccacf292cfe493dd50e56c326907fb217074/html_librarian-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6a1344d6f90b41f5c27d84ded7fd9b98", "sha256": "b0f21f6bfbb1f0b826ea95419a708619faef523c975e8f046b9ed64ebb3320aa" }, "downloads": -1, "filename": "html_librarian-0.0.1.tar.gz", "has_sig": false, "md5_digest": "6a1344d6f90b41f5c27d84ded7fd9b98", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4170, "upload_time": "2018-06-25T03:10:52", "url": "https://files.pythonhosted.org/packages/82/3a/a2ab2e3c37a37eee23371cfd5962f51f87243fcff074eab102188d4c2974/html_librarian-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "13a5428461f5ef0c1f8373fe8e5ef60b", "sha256": "e6a3b2a522cd01e613e1e5ed6aa59803772c645fd1711d56bf1c39d389379eda" }, "downloads": -1, "filename": "html_librarian-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "13a5428461f5ef0c1f8373fe8e5ef60b", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 7930, "upload_time": "2018-06-25T03:10:54", "url": "https://files.pythonhosted.org/packages/62/e8/95e1e26f806bf10f132697cbccacf292cfe493dd50e56c326907fb217074/html_librarian-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6a1344d6f90b41f5c27d84ded7fd9b98", "sha256": "b0f21f6bfbb1f0b826ea95419a708619faef523c975e8f046b9ed64ebb3320aa" }, "downloads": -1, "filename": "html_librarian-0.0.1.tar.gz", "has_sig": false, "md5_digest": "6a1344d6f90b41f5c27d84ded7fd9b98", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4170, "upload_time": "2018-06-25T03:10:52", "url": "https://files.pythonhosted.org/packages/82/3a/a2ab2e3c37a37eee23371cfd5962f51f87243fcff074eab102188d4c2974/html_librarian-0.0.1.tar.gz" } ] }