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.downloaderMiddleware.RequestsDownloaderMiddleware': 543,
}

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.1.tar.gz (5.5 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.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for scrapy-requests-manipulate-0.0.1.tar.gz
Algorithm Hash digest
SHA256 74cd198d74a1c1784ace9233a44d0855e77b0b181b0b1b4ecab3d50a0e9069c7
MD5 fb4020db44ab8418621900aad7cd1f37
BLAKE2b-256 2f76704152a0eeda9ef8df21144ae919fe79bce61ab5165b920305caa3bb1631

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for scrapy_requests_manipulate-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ede3b3fcc1fcfe04ecd3e51abe62bd6a40f95eca47783620257822b100bf3d6d
MD5 4423785e281b99bdc5528becf4d8d0d6
BLAKE2b-256 19dd2c1e86d8264e0193238d4576bc0dd34fae37cbcaa1e79c17899ad2bdcc39

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