Skip to main content

This module provides a decorator that allows to write coroutine-like spider callbacks.

The code is experimental, might not work in all cases and even might be hard to debug.

Example:

from inline_requests import inline_requests

class MySpider(CrawlSpider):

  ...

  @inline_requests
  def parse_item(self, response):
    item = self.build_item(response)

    # scrape more information
    response = yield Request(response.url + '?info')
    item['info'] = self.extract_info(response)

    # scrape pictures
    response = yield Request(response.url + '?pictures')
    item['pictures'] = self.extract_pictures(response)

    # a request that might fail (dns error, network timeout, error 404/500, etc)
    try:
      response = yield Request(response.url + '?protected')
    except Exception as e:
      log.err(e, spider=self)
    else:
      item['protected'] = self.extract_protected_info(response)

    # finally yield the item
    yield item

Example Project

The example directory includes a example spider for StackOverflow.com:

cd example
scrapy crawl stackoverflow

Requirements

  • Python 2.7+, 3.4+

  • Scrapy 1.0+

Known Issues

  • Middlewares can drop or ignore non-200 status responses causing the callback to not continue its execution. This can be overcome by using the flag handle_httpstatus_all. See the httperror middleware documentation.

  • High concurrency and large responses can cause higher memory usage.

Release files for scrapy-inline-requests 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scrapy-inline-requests 0.2.0
File Size Uploaded
scrapy-inline-requests-0.2.0.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scrapy-inline-requests 0.2.0
File Interpreter ABI Platform
scrapy_inline_requests-0.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 7.7 kB

Release files / scrapy-inline-requests-0.2.0.tar.gz

Download URL scrapy-inline-requests-0.2.0.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b8995ab28eab9aaa5324f0a11bc2197ad39e952413d038f2b4e4051a4855bd5a
BLAKE2b-256 checksum
How to use checksums
8eb49691dde4dc2092d6211b128caf23069d6e36815ac839eed70ff28b46d151
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrapy_inline_requests-0.2.0-py2.py3-none-any.whl

Download URL scrapy_inline_requests-0.2.0-py2.py3-none-any.whl
Size 4.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
5a827bb1e8f287e80be29b003edb7957a07fb11278c44ea2e74c12f708b56fdd
BLAKE2b-256 checksum
How to use checksums
404bfc449f58847a67f140d0c48c014138f863f5c4d36672a3cb7bdf3757d9b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.3.1

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page