SimpleCrawler
- This web crawler can be used to crawl a website from the command line or code
Install
- Python required (3.6+) https://www.python.org/downloads/
pip install SimpleCrawler
OR
git clone https://github.com/jackwardell/SimpleCrawler.gitcd SimpleCrawlerpython3 -m venv venvsource venv/bin/activatepip install --upgrade pippip install -r requirements.txtpip install -e .pytestcrawl https://www.example.com
Rules:
This crawler will:
- Only crawl text/html mime-types
- Only crawl pages that return 200 OK HTTP statuses
- Look at /robots.txt and obey by default (but can be overridden)
- Add User-Agent, default value = PyWebCrawler (but can be changed)
- Ignore ?query=strings and #fragments by default (but can be changed)
- Get links from ONLY href value in click here tags
Todo:
- Nicer logging
- Crawl client errors and server error pages? (Most websites have 404 & 500 handlers which may have links)
- Parse more than just tags and href attrs e.g. src='/some-link'
- Add a scheduler / wait frequency (Politeness)
- Request timeout
Use
- just type
crawl <url>into your command line e.g.crawl https://www.google.com
$ crawl --help
Usage: crawl [OPTIONS] URL
Options:
-u, --user-agent TEXT
-w, --max-workers INTEGER
-t, --timeout INTEGER
-h, --check-head
-d, --disobey-robots
-wq, --with-query
-wf, --with-fragment
--debug / --no-debug
--help Show this message and exit.
- optional params:
- "--user-agent" or "-u"
- what the User-Agent header param is
- default = 'PyWebCrawler'
- "--max-workers" or "-w"
- max number of worker threads
- default = 1
- "--timeout" or "-t"
- how long to wait for new items from work queue before shutting down
- default = 10
- "--check-head" or "-t"
- whether to send HEAD request before sending GET request
- why? some GET responses will be large (e.g. pdf) and sending HEAD request first will allow crawler to see MIME type before it makes a GET request, therefore averting the GET request altogether
- default = False
- "--disobey-robots" or "-d"
- whether to disobey robots.txt file
- default = False
- "--with-query" or "-wq"
- whether to allow query args e.g. https://www.example.com/?hello=world -> https://www.example.com/ if not --with-query
- default = False
- "--with-fragment" or "-wf"
- whether to allow fragments e.g. https://www.example.com/#helloworld -> https://www.example.com/ if not --with-fragment
- default = False
- "--debug/--no-debug", default=False
- whether to run the crawl, if debug on, then it wont crawl but will pump out crawler config
- default = False
- "--user-agent" or "-u"
OR from code
from simple_crawler import Crawler
crawler = Crawler()
found_links = crawler.crawl('https://www.example.com/')
Metadata
Release files for SimpleCrawler 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| SimpleCrawler-1.0.1.tar.gz | 16.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| SimpleCrawler-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.7 kB
Release files / SimpleCrawler-1.0.1.tar.gz
| Download URL | SimpleCrawler-1.0.1.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
482097a8f8bad29720aeef01958a1d03a5ba61599f66f27307705d9d060bd6c2
|
|
BLAKE2b-256 checksum How to use checksums |
a1b545885a387c35d841514fdd5e6f56bcaa60da8ba317adbeaf3f2450656e18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
|
Release files / SimpleCrawler-1.0.1-py3-none-any.whl
| Download URL | SimpleCrawler-1.0.1-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6a666ee8dfd7bb7ebb6a08f83f5f78be2c3ff6d04557e5f7cf1ba9ce56b7bd0
|
|
BLAKE2b-256 checksum How to use checksums |
7685db01dbf753d8e59e742625591556426a4818ef2168345213ab4d6dfaeb49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
|
Security for SimpleCrawler 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.