Closed this-is-r-gaurav closed 5 years ago
Solved The Issue Thanks i was passing Crawlrunner object as Parameter, as the function stop. The Object gets destroyed. This leads to Stop Iteration Error I guess
Hi, i have the same error occuring when i run a spider within a flask app but i don't get a response from the spider i am using flask, crochet(1.12.0), scrapyd, twisted(19.10.0)
Solved The Issue Thanks i was passing Crawlrunner object as Parameter, as the function stop. The Object gets destroyed. This leads to Stop Iteration Error I guess
I am using the same method and facing same issue. how did you resolve it. any help would be great
Hello my brother I have the same issue.
The Reactor Code look like this, which call upon GeneralSpider which fetches all the necessary data based on the pk as primary key.
runner = CrawlerRunner()
output = []
@run_in_reactor
def scraped_by_id(pk):
global runner
dispatcher.connect(_crawler_result, signal=signals.item_scraped)
eventual = runner.crawl(GeneralSpider, id=pk)
dispatcher.connect(_crawler_Stop, signals.engine_stopped)
return eventual
def _crawler_result(item, response, spider):
global output_data
output_data.append(dict(item))
def _crawler_Stop():
# Perform any operation which is relevant to your application, like notify user
pass
And my GeneralSpider class look like this. Where Job contains info like url to scrape, fields to scrape, etc.
class GeneralSpider(scrapy.Spider):
def __init__(self, id, **kwargs):
self.id = id
self.custom_settings = {"LOG_LEVEL": "DEBUG"}
job = Job.objects.get(pk=id)
Hope this helps @MarwaKH29 @HimavarshaVS @dzhen19
Can you please show the code for def _crawler_Stop() ? And also my imagePipeline and deltafetch middleware are also not working??
I am trying to Integrate Django With Scrapy and for running Crawler with
run_in_reactor
instead ofwait for
as shown in example How to integrate Flask & Scrapy? But This raises errorWhat i want is After Running the function which is decorated by
run_in_reactor
the user of the program get alert that the function is called successfully. And as the result finished, it doesn't lead to this error