1
2
mirror of https://github.com/vimagick/dockerfiles synced 2024-06-16 03:48:44 +00:00
dockerfiles/scrapyd
2015-09-20 18:19:43 +08:00
..
onbuild fix 2015-06-01 11:42:11 +08:00
Dockerfile add scrapyjs to scrapyd 2015-09-20 18:19:43 +08:00
README.md add scrapyjs to scrapyd 2015-09-20 18:19:43 +08:00
scrapyd.conf update 2015-05-28 23:12:26 +08:00

scrapyd

Scrapy is an open source and collaborative framework for extracting the data you need from websites. In a fast, simple, yet extensible way.

Scrapyd is a service for running Scrapy spiders. It allows you to deploy your Scrapy projects and control their spiders using a HTTP JSON API.

Scrapyd-client is a client for scrapyd. It provides the scrapyd-deploy utility which allows you to deploy your project to a Scrapyd server.

ScrapyJS provides Scrapy+JavaScript integration using Splash.

This image is based on debian:jessie without any useless packages installed. Only 4 latest python packages are installed:

Please use this image as base for your own project.

Run it as background-daemon for scrapyd

$ docker run -d --restart always --name scrapyd -p 6800:6800 vimagick/scrapyd
$ firefox http://localhost:6800

Run it as interactive-shell for scrapy

$ cat > stackoverflow_spider.py << _EOF_
import scrapy

class StackOverflowSpider(scrapy.Spider):
    name = 'stackoverflow'
    start_urls = ['http://stackoverflow.com/questions?sort=votes']

    def parse(self, response):
        for href in response.css('.question-summary h3 a::attr(href)'):
            full_url = response.urljoin(href.extract())
            yield scrapy.Request(full_url, callback=self.parse_question)

    def parse_question(self, response):
        yield {
            'title': response.css('h1 a::text').extract()[0],
            'votes': response.css('.question .vote-count-post::text').extract()[0],
            'body': response.css('.question .post-text').extract()[0],
            'tags': response.css('.question .post-tag::text').extract(),
            'link': response.url,
        }
_EOF_

$ docker run -it --rm -v `pwd`:/code -w /code vimagick/scrapyd bash
>>> scrapy runspider stackoverflow_spider.py -o top-stackoverflow-questions.json
>>> cat top-stackoverflow-questions.json
>>> exit