Skip to main content

API for Scrapy spiders

Project description

ArachneServer

[![Build Status](https://travis-ci.org/dmkitui/arachneserver.svg?branch=master)](https://travis-ci.org/dmkitui/arachneserver) [![Coverage Status](https://coveralls.io/repos/github/dmkitui/arachneserver/badge.svg?branch=master)](https://coveralls.io/github/dmkitui/arachneserver?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/637b135299638812096d/maintainability)](https://codeclimate.com/github/dmkitui/arachneserver/maintainability)

ArachneServer provides a wrapper around your scrapy Spider object to run them through a flask app. All you have to do is customize SPIDER_SETTINGS in the settings file.

Installation

You can install ArachneServer from pip

pip install ArachneServer

Sample settings

This is sample settings file for spiders in your project. The settings file should be called settings.py in the root of your project for ArachneServer to find it and looks like this:

# settings.py file
SPIDER_SETTINGS = [
        {
                'endpoint': 'dmoz',
                'location': 'spiders.DmozSpider',
                'endpoints_location: 'spiders.DmozSpider_endpoints'
                'spider': 'DmozSpider'
        }
]

Usage

It looks very similar to a flask app but since Scrapy depends on the python twisted package, we need to run our flask app with twisted:

from twisted.web.wsgi import WSGIResource
from twisted.web.server import Site
from twisted.internet import reactor
from arachneserver import ArachneServer

app = ArachneServer(__name__)

resource = WSGIResource(reactor, reactor.getThreadPool(), app)
site = Site(resource)
reactor.listenTCP(8080, site)

if __name__ == '__main__':
        reactor.run()

Endpoints

Two default endpoints are provided for every spider:
  1. ‘/’ - List all spiders.

  2. ‘/run-spider/<spider_name>’ - To run the specified spider.

Specify additional endpoints for each spider and update the respective SPIDER_SETTINGS dictionary’s endpoints_location to point to the correct path to the endpoints file.

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

ArachneServer-1.0.2.tar.gz (8.3 kB view details)

Uploaded Source

File details

Details for the file ArachneServer-1.0.2.tar.gz.

File metadata

  • Download URL: ArachneServer-1.0.2.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.5

File hashes

Hashes for ArachneServer-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a145beb9c417f350c38919d75a2caeb0a07a1c9579b5e87661d1b82f60400fdf
MD5 7360aa33cf7285fb8c13187af7e1e6e0
BLAKE2b-256 75b6650e4e5fd4c3727a5ac9914ec0c2869ac760462fcc12aa679bda3a85c0f5

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