Skip to main content

requests downloader middleware for scrapy, send request by requests.

Project description

Scrapy Requests Downloader Middleware

This package will make scrapy support requests. Everything is same with requests.

Installation

pip3 install scrapy-requests-manipulate

Usage

After add this middleware, all requests will be sent by requests.

The usage is very simple, for request, specify params in meta.

Settings for Request

params = {
    'key1': 'value1',
    'key2': 'value2',
}
data = {
    'key1': 'value1',
    'key2': 'value2',
}
# turn cookie jar into dict, and remove the " mark, use ' mark
cookies = {
    'key1': 'value1',
    'key2': 'value2',
}
payload = {
    'key1': 'value1',
    'key2': 'value2'
}
proxy_ = 'http://username:password@ip:port' # https also works
or 
proxy_ = [
    'http://username:password@ip:port',
    'http://username:password@ip:port',
] # if the type of proxy is list, every request will get a random proxy in the list

meta_data = {
    'params': params,
    'data': data,
    'cookies': cookies,
    'json': payload,
    'proxy_': proxy_
}
or 
meta_data = {
    'params': json.dumps(params),
    'data': json.dumps(data),
    'cookies': json.dumps(cookies),
    'json': json.dumps(payload),
    'proxy_': json.dumps(proxy_)
}
yield scrapy.Request(url=url, headers=headers, meta=meta_data)

And you also need to enable RequestsDownloaderMiddleware in DOWNLOADER_MIDDLEWARES:

DOWNLOADER_MIDDLEWARES = {
    'scrapy_requests_manipulate.downloaderMiddleware.RequestsDownloaderMiddleware': 543,
    'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware': None,
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scrapy-requests-manipulate-0.0.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scrapy_requests_manipulate-0.0.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file scrapy-requests-manipulate-0.0.2.tar.gz.

File metadata

File hashes

Hashes for scrapy-requests-manipulate-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1bd0119ad8f0a2c51ca9b6300cdf7cb2868e4cd77a4654bb9195cef4d0a435d1
MD5 3ffddd9d7b7f47d8b3f20f28790137fd
BLAKE2b-256 ccf2debc7f6ec0340126ccfad80657b144df34f80fa6c70ebefa334e47fa9cc6

See more details on using hashes here.

File details

Details for the file scrapy_requests_manipulate-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for scrapy_requests_manipulate-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 46893c00255906d2789d2c8efe8abf825ef115499f3ca1519cd39ee77acffec6
MD5 8ef90923046931414436ab71ff167598
BLAKE2b-256 e2d092f481b49b4b30871eedf91650c90eebdc28fd30843a37fbddbd1086ae6a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page