Website crawler-ish thing?
Project description
Webster
Webster is an experimental python web scraping framework for my own learning.
Webster can be used to scrape or download webpages by giving a list of urls to visit and optionally a list of urls to stay within.
Webster could be used as a broad crawler also, but it is not optimized for that as of now.
Version
Webster has been tested using Python 3.10+
Project documentation
Installation
Install Webster using one off the following methods
From requirements.txt
pip install -r requirements.txt
Dependencies
Webster is using multiple external Python packages some of which are:
- lxml used for processing html documents.
- w3lib used for URL handling and prosessing.
- pycURL used for networking and making requests to a http server.
- pymongo tools for working with mongoDB using python
Use pipreqs to make new requirements.txt if new dependencies are added in PR force over requirements.txt and make sure to include the new one in PR.
pipreqs --force
Update dependencies if necessary
pip install -U -r requirements.txt
Testing
Webster uses unittest for testing.
To run all the tests use the following command:
python -m unittest discover -v
Example: We want to test Parser module To run single module test use the following command:
python -m unittest test.test_parser -v
Coverage
To run test coverage use the coverage module
python -m coverage run -m unittest
To show coverage report in terminal
python -m coverage report
Output should look something like this.
Name Stmts Miss Cover
-----------------------------------------------------
test/__init__.py 0 0 100%
test/test_data/__init__.py 10 0 100%
test/test_downloader.py 43 1 98%
test/test_parser.py 54 1 98%
test/test_request.py 49 2 96%
test/test_robotstxt.py 23 1 96%
test/test_url_tools.py 22 1 95%
test/test_validators.py 53 1 98%
webster/__init__.py 0 0 100%
webster/conf/__init__.py 0 0 100%
webster/conf/settings.py 9 0 100%
webster/core/__init__.py 0 0 100%
webster/core/downloader.py 36 8 78%
webster/core/parser.py 40 1 98%
webster/net/__init__.py 0 0 100%
webster/net/request/__init__.py 47 2 96%
webster/pipelines/__init__.py 0 0 100%
webster/robotstxt.py 15 2 87%
webster/utils/__init__.py 0 0 100%
webster/utils/url_tools.py 15 0 100%
webster/utils/validators.py 16 7 56%
-----------------------------------------------------
TOTAL 432 27 94%
For a nicer report and more detailed use the html report
python -m coverage html
open htmlcov/index.html
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
BSD 3-Clause License
Copyright (c) 2022, Henri Remonen. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for webster_crawler-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6991d6c156345deb3862aa73f5cb1e87e6fe2db1f3564f70ec007c89b0a2bfae |
|
MD5 | 1ee4dfe7bf053736f566f35ef31d9e69 |
|
BLAKE2b-256 | 93ba5aace93a4d6e263d321875a959db8bc16cbeea61576eeb9b55fdb2f61959 |