Skip to content

Instantly share code, notes, and snippets.

@eventuallyc0nsistent
Created May 22, 2015 16:06
Show Gist options
  • Save eventuallyc0nsistent/92a825a0fae102f3c0d5 to your computer and use it in GitHub Desktop.
Save eventuallyc0nsistent/92a825a0fae102f3c0d5 to your computer and use it in GitHub Desktop.
Querying a Scrapy spider with JSON RPC
import requests
url = 'http://localhost:6080/crawler'
# This will call the crawler objects stop method.
# Checkout all the methods the crawler object has:
# https://github.com/scrapy/scrapy/blob/master/scrapy/crawler.py#L24
data = '{"id" : 2, "method" : "stop"}'
# The project has been moved out of scrapy but heres the web service API
# https://github.com/scrapy/scrapy-jsonrpc/blob/master/scrapy_jsonrpc/webservice.py
requests.post(url, data=data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment