Last active
December 23, 2015 22:29
-
-
Save amferraz/6703206 to your computer and use it in GitHub Desktop.
An example of ItemPipeline with FollowAllSpider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import reactor | |
from scrapy.crawler import Crawler | |
from scrapy.settings import Settings | |
from scrapy import signals | |
from testspiders.spiders.followall import FollowAllSpider | |
class MyPipeline(object): | |
def process_item(self, item, spider): | |
print item['url'] | |
spider = FollowAllSpider(domain='scrapinghub.com') | |
# take a look | |
# https://scrapy.readthedocs.org/en/latest/topics/item-pipeline.html?#activating-an-item-pipeline-component | |
settings = Settings( | |
{ | |
'ITEM_PIPELINES': { | |
'main.MyPipeline': 1 | |
} | |
} | |
) | |
crawler = Crawler(settings) | |
crawler.signals.connect(reactor.stop, signal=signals.spider_closed) | |
crawler.configure() | |
crawler.crawl(spider) | |
crawler.start() | |
crawler.stats | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment