robotsparse
A python package that enhances speed and simplicity of parsing robots files.
Usage
Basic usage, such as getting robots contents:
import robotsparse
#NOTE: The `find_url` parameter will redirect the url to the default robots location.
robots = robotsparse.getRobots("https://github.com/", find_url=True)
print(list(robots)) # output: ['user-agents']
The user-agents key will contain each user-agent found in the robots file contents along with information associated with them.
Alternatively, we can assign the robots contents as an object, which allows faster accessability:
import robotsparse
# This function returns a class.
robots = robotsparse.getRobotsObject("https://duckduckgo.com/", find_url=True)
assert isinstance(robots, object)
print(robots.allow) # Prints allowed locations
print(robots.disallow) # Prints disallowed locations
print(robots.crawl_delay) # Prints found crawl-delays
print(robots.robots) # This output is equivalent to the above example
Additional Features
When parsing robots files, it sometimes may be useful to parse sitemap files:
import robotsparse
sitemap = robotsparse.getSitemap("https://pypi.org/", find_url=True)
The above code contains a variable named sitemap which contains information that looks like this:
[{"url": "", "lastModified": ""}]
Metadata
Release files for robotsparse 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| robotsparse-1.0.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| robotsparse-1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.5 kB
Release files / robotsparse-1.0.tar.gz
| Download URL | robotsparse-1.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bed0da0873c055653e39cc67bbea96fb8c9de3d1e7c5ada77003d7b86615479
|
|
BLAKE2b-256 checksum How to use checksums |
9afcd560faeb84d68802cc3ab4459a5353cedaadf021e9aee6ed08626936a577
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|
Release files / robotsparse-1.0-py3-none-any.whl
| Download URL | robotsparse-1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aad90a9604b8ca94f47e0a151f6352e356512c48dc52140245d7a8591996d736
|
|
BLAKE2b-256 checksum How to use checksums |
6d309ee2722e62100da6ac9f15fcbdb75d818aa06cdf2bc401e86a85e1e1275e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|