Skip to main content

IP filtered DNS Resolver

Project description

os-scrapy-ipfilter-resolver

Build Status codecov PyPI - Python Version PyPI

This project provide a DNS Resolver for ip blacklist/whitelist and config DNS expire time.

Install

pip install os-scrapy-ipfilter-resolver

You can run example spider directly in the project root path.

scrapy crawl example

Usage

Settings

  • enable DNS Resolver, in the project settings.py file:

    DNS_RESOLVER = "os_scrapy_ipfilter_resolver.Resolver"
    
  • config IP blacklist, it will raise IPFilteredException when the request ip in the blacklist

    IP_DISALLOWED = ["192.168.0.0/16", "10.143.0.1"]
    
  • config IP whitelist, priority greater than blacklist

    IP_ALLOWED = ["192.168.0.1"]
    
  • config DNS cache size and expire time(seconds)

    DNSCACHE_ENABLED = True
    DNSCACHE_SIZE = 10000
    DNSCACHE_EXPIRE = 24 * 60 * 60
    
  • config DNS lookup timeout(seconds)

    DNS_TIMEOUT = 60
    

Unit Tests

tox

License

MIT licensed.

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

os_scrapy_ipfilter_resolver-0.0.4.tar.gz (6.9 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