Skip to main content

Auto Generated by os-scrapy-cookiecutter

Project description

os-scrapy-uvicorn

Build Status codecov PyPI - Python Version PyPI

This project provide a extension to start a ASGI http server(Uvicorn) along with Scrapy in the same process.

You can use the ASGI framework(recommend FastAPI) to create app to communicate with Scrapy.

Require: Python 3.6+, Scrapy 2.0+

Install

pip install os-scrapy-uvicorn

You can run example spider directly in the project root path

scrapy crawl example

Settings

  • use asyncio reactor

    TWISTED_REACTOR = "twisted.internet.asyncioreactor.AsyncioSelectorReactor"
    

    or you can use os-scrapy(installed with this project) to start crawling with -r command line option

    os-scrapy crawl -r asyncio example
    
  • enable extension

    EXTENSIONS = {
        "os_scrapy_uvicorn.Uvicron": 1,
    }
    
  • app path, you can use ASGI app frameworks to create your app, FastAPI is recommended

    UVICORN_APP = "app_module:app"
    
  • uvicorn server settings, supported settings

    UVICORN_CONFIG = {"host": "0.0.0.0", "port": 5000}
    
  • when the server started, Scrapy crawler instance is attached to the app, it is the entrypoint to commnicate with Scrapy

Unit Tests

sh scripts/test.sh

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_uvicorn-0.0.1.tar.gz (7.3 kB view details)

Uploaded Source

File details

Details for the file os_scrapy_uvicorn-0.0.1.tar.gz.

File metadata

  • Download URL: os_scrapy_uvicorn-0.0.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.7

File hashes

Hashes for os_scrapy_uvicorn-0.0.1.tar.gz
Algorithm Hash digest
SHA256 37bee1f829317d692b5205b44acefa88cb87b3cfab55e6d017fedc5c8ada89bb
MD5 e4347d515cb30ab1e4de81b371902212
BLAKE2b-256 89aa846d31e159a29927f959ca112f03764783e65dc410e50a00290814954926

See more details on using hashes here.

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