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.
Metadata
Release files for os-scrapy-record 0.0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| os-scrapy-record-0.0.15.tar.gz | 10.4 kB | Details |
Release files / os-scrapy-record-0.0.15.tar.gz
| Download URL | os-scrapy-record-0.0.15.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb82c668c620c524fa50bb8397bd5724ca27bd2bccc60289d9da26ba0e7863f5
|
|
BLAKE2b-256 checksum How to use checksums |
4d67504dac092a1fa7d1a5cf57f0d608928232db6a65d2c13a5d6438805d0e24
|
| 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.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.7
|