About
This is Scrapy downloader middleware that stores response HTMLs to disk.
Usage
Turn downloader on, e.g. specifying it in settings.py:
DOWNLOADER_MIDDLEWARES = {
'scrapy_html_storage.HtmlStorageMiddleware': 10,
}
None of responses by default are saved to disk. You must select for which requests the response HTMLs will be saved:
def parse(self, response):
"""Processes start urls.
Args:
response (HtmlResponse): scrapy HTML response object.
"""
yield scrapy.Request(
'http://target.com',
callback=self.parse_target,
meta={
'save_html': True,
}
)
The file path where HTML will be stored is resolved with spider method response_html_path. E.g.:
class TargetSpider(scrapy.Spider):
def response_html_path(self, request):
"""
Args:
request (scrapy.http.request.Request): request that produced the
response.
"""
return 'html/last_response.html'
Configuration
HTML storage downloader middleware supports such options:
gzip_output (bool) - if True, HTML output will be stored in gzip format. Default is False.
save_html_on_status (list) - if not empty, sets list of response codes whitelisted for html saving. If list is empty or not provided, all response codes will be allowed for html saving.
Sample:
HTML_STORAGE = {
'gzip_output': True,
'save_html_on_status': [200, 202]
}
Metadata
Release files for scrapy-html-storage 0.4.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 | Provenance | Actions |
|---|---|---|---|---|
| scrapy-html-storage-0.4.0.tar.gz | 3.0 kB | Without provenance | Details for scrapy-html-storage-0.4.0.tar.gz |
Release files / scrapy-html-storage-0.4.0.tar.gz
| Download URL | scrapy-html-storage-0.4.0.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7b55bb5025efe8c545b4d9fdcf357bb9a4bbaa17265f68ec093615dd5672fdc
|
|
BLAKE2b-256 checksum How to use checksums |
7815f7a99fbfa63298323b8288695f34c21095410d4739a5368fd0b0bb0f7f1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for scrapy-html-storage 0.4.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.