Parse robots.txt
Project description
robotsparsetools
robots.txt is important when crawling website
This module will help you parse robots.txt
Install
.. code:: bash
$ pip install robotsparsetools
Usage
Parse
Please create an Parse instance first
.. code:: python
from robotsparsetools import Parse
url = "URL of robots.txt you want to parse"
p = Parse(url) # Create an instance. Returns a Parse class with the useragent as the key
# Get allow list
p.Allow(useragent)
# Get disallow list
p.Disallow(useragent)
# Get value of Crawl-delay(Return value is int or None)
p.delay(useragent)
# Find out if crawls are allowed
p.can_crawl(url, useragent)
If no useragent is specified, the value of '*' will be referenced
Also, since the Parse class inherits from dict, you can also use it like dict
.. code:: python
from robotsparsetools import Parse
p = Parse(url)
p["*"]
p.get("*") # Can also use get method
Read(✨ new in 1.2.1)
You can parse its contents by passing a text or local path to Read
.. code:: python
from robotsparsetools import Read
import requests
url = "URL of robots.txt you want to parse"
r = requests.get(url)
p = Read(r.text)
path = "File path of robots.txt you want to parse"
p = Read(path)
The return value is a Parse instance
Error Classes
Also, there are two error classes
.. code:: python
from robotsparsetools import NotURLError, NotFoundError
License
This program's license is
MIT <https://github.com/mino-38/robotsparsetools/blob/main/LICENSE>__
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file robotsparsetools-1.2.2.tar.gz.
File metadata
- Download URL: robotsparsetools-1.2.2.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
879dd30e06ed2f307bab478a7cdb5181d1243dd81e2f2c8f05ab7c938b9f2748
|
|
| MD5 |
7da8562ed705917e142d4dba6332655f
|
|
| BLAKE2b-256 |
e6c17f7d4ae33b634d0fe04a91f324cd470ddc2c6c522750ec7b44f1925eeaed
|
File details
Details for the file robotsparsetools-1.2.2-py3-none-any.whl.
File metadata
- Download URL: robotsparsetools-1.2.2-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c9ad1023acf16e9c420ed1756245f14bc61b3789dcc8d40282ac0f9f0cae004
|
|
| MD5 |
6884f635e8f5e2a5c9fc1eb80fae66ae
|
|
| BLAKE2b-256 |
dcc32578449f6ea4c57e0a1b02f0506d9a508c147253db549d7e3eacfedfe3f5
|