Scrapy Item Record Extension
Project description
os-scrapy-record
This project provide extensions to process Response/Failure, generate standard Item.
Install
pip install os-scrapy-record
You can run example spider directly in the project root path
scrapy crawl example
APIs
-
os_scrapy_record.ResponseCallback- the
callbackmethod of this extension will replace the defaultRequest.callback, process Response and generate FetchRecord - the
callbackmethod will not work when the request already set callback function - the
callbackmethod will override theparsemethod of spider - enable extension in the project settings.py file:
EXTENSIONS = { "os_scrapy_record.ResponseCallback": 1, } - the
-
os_scrapy_record.ResponseErrback- the
errbackmethod of this extension will replace the defaultRequest.errback, process Failure and generate FetchRecord - the
errbackmethod will not work when the request already set errback function - enable extension in the project settings.py file:
EXTENSIONS = { "os_scrapy_record.ResponseErrback": 1, } - the
-
os_scrapy_record.FetchRecordThis class is subclass of Item
the mumbers of this class are:
- request:
os_scrapy_record.items.RequestItem, members: url, method, headers, body - meta:
dict, request.meta, it is better to use lower case and '_' as separator as key - response:
os_scrapy_record.items.ResponseItem,members: headers, body, status, ip_address(Scrapy 2.1.0+), failure
- request:
-
os_scrapy_record.fetch_status.FetchStatusA mumber of ResponseItem, include HTTP, DNS, Network and user defined status. It is a two-tuple object: group and code. e.g, HTTP:200, DNS:-2, SERVER:111, RULE:16
Unit Tests
sh scripts/test.sh
License
MIT licensed.
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
File details
Details for the file os-scrapy-record-0.0.10.tar.gz.
File metadata
- Download URL: os-scrapy-record-0.0.10.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7e9e28f7fbf1233365662ccbc2f09bed9932e237c6df599e4490233eeab4f85
|
|
| MD5 |
fba8b3e46a176d138457901f5e2c6fd4
|
|
| BLAKE2b-256 |
a02f6d7b1e3a79c9afa2173d05f4348585c6b61e2a0ca371e6e15bf394f9c3f3
|