Last active
September 21, 2018 04:52
-
-
Save IAlwaysBeCoding/2dbfa1a301a4da60e677ad1f6ed0c354 to your computer and use it in GitHub Desktop.
Revisions
-
IAlwaysBeCoding revised this gist
Sep 21, 2018 . No changes.There are no files selected for viewing
-
IAlwaysBeCoding revised this gist
Sep 21, 2018 . No changes.There are no files selected for viewing
-
IAlwaysBeCoding revised this gist
Sep 21, 2018 . No changes.There are no files selected for viewing
-
IAlwaysBeCoding revised this gist
Sep 21, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ from scrapy import Request class SynchronousSpiderMiddleware(object): @@ -24,4 +25,4 @@ def process_spider_output(self, response, result, spider): yield request if step == 'parse': yield listing_request -
IAlwaysBeCoding renamed this gist
Sep 21, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
IAlwaysBeCoding created this gist
Sep 21, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ from scrapy import Request class SynchronousSpiderMiddleware(object): def process_spider_output(self, response, result, spider): listing_request = None for request in result: step = request.meta.get('step', None) if step == 'parse': if not listing_request: listing_request = request listings = listing_request.meta.get('listings', []) listings.append(request) continue elif step == 'result': listings = request.meta.get('listings', []) request = listings.pop(0) yield request if step == 'parse': yield listing_request