Skip to main content

Scrapy decorator for inline requests

Project description

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.


from inline_requests import inline_requests

class MySpider(CrawlSpider):


  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)
      response = yield Request(response.url + '?protected')
    except Exception as e:
      log.err(e, spider=self)
      item['protected'] = self.extract_protected_info(response)

    # finally yield the item
    yield item

Example Project

The example directory includes a example spider for

cd example
scrapy crawl stackoverflow


  • 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.

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-inline-requests-0.2.0.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

scrapy_inline_requests-0.2.0-py2.py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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