Skip to main content

Scrapy download handler that can impersonate browser TLS signatures

Project description

scrapy-rnet

A Scrapy download handler that enables browser TLS fingerprint impersonation using the rnet library.

Features

  • Seamlessly integrates with Scrapy's download system
  • Impersonates browser TLS signatures to evade detection
  • Supports multiple browser versions for impersonation

Installation

pip install scrapy-rnet

Requirements

  • Python 3.12+
  • rnet >= 2.1.0
  • scrapy >= 2.12.0

Usage

Basic Setup

  1. Configure the download handlers in your Scrapy settings:
DOWNLOAD_HANDLERS = {
    "http": "scrapy_rnet.handler.ImpersonateDownloadHandler",
    "https": "scrapy_rnet.handler.ImpersonateDownloadHandler",
}
USER_AGENT = None

# Required for async operation
TWISTED_REACTOR = "twisted.internet.asyncioreactor.AsyncioSelectorReactor"
  1. Enable impersonation for specific requests by adding impersonate to the request metadata:
from rnet import Impersonate, ImpersonateOS

yield scrapy.Request(
    url="https://example.com",
    meta={
        "impersonate": Impersonate.Chrome132,
        "impersonate_os": ImpersonateOS.Windows # Optional
    },
    callback=self.parse
)

Example Spider

import scrapy
from scrapy.http import Request, Response
from rnet import Impersonate, ImpersonateOS

class BrowserImpersonationSpider(scrapy.Spider):
    name = "browser_impersonation"
    
    custom_settings = {
        "DOWNLOAD_HANDLERS": {
            "http": "scrapy_rnet.handler.ImpersonateDownloadHandler",
            "https": "scrapy_rnet.handler.ImpersonateDownloadHandler",
        },
        "TWISTED_REACTOR": "twisted.internet.asyncioreactor.AsyncioSelectorReactor",
        "USER_AGENT": None
    }
    
    def start_requests(self):
        url = "https://httpbin.org/headers"
        yield Request(
            url=url,
            meta={
                "impersonate": Impersonate.Chrome132,
                "impersonate_os": ImpersonateOS.Windows # Optional
            },
            callback=self.parse
        )
    
    def parse(self, response):
        self.logger.info(response.text)

Available Impersonation Options

The package supports a wide range of browser versions and operating systems:

Browser Versions

Browser Versions
Chrome Chrome100, Chrome101, Chrome104, Chrome105, Chrome106, Chrome107, Chrome108, Chrome109, Chrome114, Chrome116, Chrome117, Chrome118, Chrome119, Chrome120, Chrome123, Chrome124, Chrome126, Chrome127, Chrome128, Chrome129, Chrome130, Chrome131, Chrome132, Chrome133, Chrome134
Edge Edge101, Edge122, Edge127, Edge131, Edge134
Safari SafariIos17_2, SafariIos17_4_1, SafariIos16_5, Safari15_3, Safari15_5, Safari15_6_1, Safari16, Safari16_5, Safari17_0, Safari17_2_1, Safari17_4_1, Safari17_5, Safari18, SafariIPad18, Safari18_2, Safari18_1_1, Safari18_3, Safari18_3_1
OkHttp OkHttp3_9, OkHttp3_11, OkHttp3_13, OkHttp3_14, OkHttp4_9, OkHttp4_10, OkHttp4_12, OkHttp5
Firefox Firefox109, Firefox117, Firefox128, Firefox133, Firefox135, FirefoxPrivate135, FirefoxAndroid135, Firefox136, FirefoxPrivate136

Operating Systems

  • Windows
  • MacOS
  • Linux
  • Android
  • IOS

Credits

0x676e67 for Rnet

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_rnet-0.0.3.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

scrapy_rnet-0.0.3-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file scrapy_rnet-0.0.3.tar.gz.

File metadata

  • Download URL: scrapy_rnet-0.0.3.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.14

File hashes

Hashes for scrapy_rnet-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ddfa2b44b84e226858d73f6df967bcf68a5979f49ea1d64b7cd5903ca1316bf5
MD5 671fb15180d5c2c8ab345dc67b01694f
BLAKE2b-256 931a1342ea7711730a31eaa6e26cef0a1e23af752a5eeef5cde98044d5fd000c

See more details on using hashes here.

File details

Details for the file scrapy_rnet-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for scrapy_rnet-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0fd62228dd9e1b28df99405d74b3fd0f8550f6d50863738f536087b3d94b3281
MD5 7eb02f1e42d3a3e58ef69176cc804ba7
BLAKE2b-256 eebd7b420bf23c564d004e7bd9f69ec8fe7a8552ce8683d263b74202bef5c94f

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