Skip to main content

Scrapy Crawlbase Proxy Middleware: Crawlbase interfacing middleware for Scrapy

Project description

Crawlbase API middleware for Scrapy

Processes Scrapy requests using Crawlbase services either with Normal or Javascript tokens

Installing

Choose a way of installing:

  • Clone the repository inside your Scrapy project and run the following:
python setup.py install
  • Or use PyPi Python package manager. pip install scrapy-crawlbase-middleware

Then in your Scrapy settings.py add the following lines:

# Activate the middleware
CRAWLBASE_ENABLED = True

# The Crawlbase API token you wish to use, either normal of javascript token
CRAWLBASE_TOKEN = 'your token'

# Enable the middleware
DOWNLOADER_MIDDLEWARES = {
    'scrapy_crawlbase.CrawlbaseMiddleware': 610
}

Usage

Use the scrapy_crawlbase.CrawlbaseRequest instead of the scrapy built-in Request. The scrapy_crawlbase.CrawlbaseRequest accepts additional arguments, used in Proxy Crawl API:

from scrapy_crawlbase import CrawlbaseRequest

class ExampleScraper(Spider):

    def start_requests(self):
        yield CrawlbaseRequest(
            "http://target-url",
            callback=self.parse_result
            device='desktop',
            country='US',
            page_wait=1000,
            ajax_wait=True,
            dont_filter=True
        )

The target url will be replaced with proxy crawl url and parameters will be encoded into the url by the middleware automatically.

If you have questions or need help using the library, please open an issue or contact us.


Copyright 2023 Crawlbase

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-crawlbase-middleware-1.0.0.tar.gz (5.0 kB view hashes)

Uploaded Source

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