robotsparser
Python library that parses robots.txt files
Functionalities
- Automatically discover all sitemap files
- Unzip gziped files
- Fetch all URLs from sitemaps
Install
pip install robotsparser
Usage
from robotsparser.parser import Robotparser
robots_url = "https://www.example.com/robots.txt"
rb = Robotparser(url=robots_url, verbose=True)
# To initiate the crawl of sitemaps and indexed urls. sitemap_crawl_limit argument is optional
rb.read(fetch_sitemap_urls=True, sitemap_url_crawl_limit=5)
# Show information
rb.get_sitemap_indexes() # returns sitemap indexes
rb.get_sitemaps() # returns sitemaps
rb.get_urls() # returns a list of all urls
Crawl in the background using thread
Crawl in the background and output new entries to file
This is useful for sites where sitemaps are heavily nested and take a long time to crawl
from robotsparser.parser import Robotparser
import threading
if __name__ == '__main__':
robots_url = "https://www.example.com/robots.txt"
rb = Robotparser(url=robots_url, verbose=False)
sitemap_crawl_proc = threading.Thread(target = rb.read, kwargs = {'fetch_sitemap_urls': False}, daemon=True)
sitemap_crawl_proc.start()
while sitemap_crawl_proc.is_alive():
time.sleep(1)
print(f"entries_count: {len(rb.get_sitemap_entries())}, indexes: {len(rb.get_sitemap_indexes())}")
# any logic here to get object data
Metadata
Release files for robotsparser 0.0.12
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 | |
|---|---|---|---|---|
| robotsparser-0.0.12.tar.gz | 5.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| robotsparser-0.0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.3 kB
Release files / robotsparser-0.0.12.tar.gz
| Download URL | robotsparser-0.0.12.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d6ad16e41f6d13d31d7d29c2fb9f58a7c612299bb3d2e40d697f082af545023
|
|
BLAKE2b-256 checksum How to use checksums |
c0fea88d6490d381cbd95c49e88551b97d64fd6714fd454044988afb6527113f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / robotsparser-0.0.12-py3-none-any.whl
| Download URL | robotsparser-0.0.12-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
00400bfa27e1d0f7d7e9bd6461ba145b7252405d9e6a595ff1930f9ca754b3c3
|
|
BLAKE2b-256 checksum How to use checksums |
ce4b82dc9b5f373f2a11a71c23716fec6635d4ab03ab8f8db8953535a1c6b72a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for robotsparser 0.0.12
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.