twisted

Scrapy crawl from script always blocks script execution after scraping

穿精又带淫゛_ 提交于 2019-11-26 11:10:32
问题 I am following this guide http://doc.scrapy.org/en/0.16/topics/practices.html#run-scrapy-from-a-script to run scrapy from my script. Here is part of my script: crawler = Crawler(Settings(settings)) crawler.configure() spider = crawler.spiders.create(spider_name) crawler.crawl(spider) crawler.start() log.start() reactor.run() print \"It can\'t be printed out!\" It works at it should: visits pages, scrape needed info and stores output json where I told it(via FEED_URI). But when spider

Django Push HTTP Response to users [closed]

夙愿已清 提交于 2019-11-26 08:48:03
问题 I currently have a very simple web application written in Django, and I would like to implement something like a callback/push notification service in my application. For example: When one user(client) uploads a photo to the server, the server notifies all other connected users about that photo. I suppose I can use Django signals to produce a callback when a user uploads a photo, but how do I get Django to post a notification to the other users? This notification could either be alerts or

ReactorNotRestartable error in while loop with scrapy

我们两清 提交于 2019-11-26 05:58:50
问题 I get twisted.internet.error.ReactorNotRestartable error when I execute following code: from time import sleep from scrapy import signals from scrapy.crawler import CrawlerProcess from scrapy.utils.project import get_project_settings from scrapy.xlib.pydispatch import dispatcher result = None def set_result(item): result = item while True: process = CrawlerProcess(get_project_settings()) dispatcher.connect(set_result, signals.item_scraped) process.crawl(\'my_spider\') process.start() if