Beispiel #1
0
 def cb_wrapper(response):
     try:
         output = cb(response)
         output = list(iterate_spider_output(output))
     except:
         case = _create_testcase(method, 'callback')
         results.addError(case, sys.exc_info())
Beispiel #2
0
    def _parse_response(self, response, callback, cb_kwargs, follow=True):
        if callback:
            cb_res = callback(response, **cb_kwargs) or ()
            cb_res = self.process_results(response, cb_res)
            for requests_or_item in iterate_spider_output(cb_res):
                yield requests_or_item

        if follow and self._follow_links:
            for request_or_item in self._requests_to_follow(response):
                yield request_or_item
Beispiel #3
0
 def wrapper(response):
     try:
         results.startTest(self.testcase_pre)
         self.pre_process(response)
         results.stopTest(self.testcase_pre)
     except AssertionError:
         results.addFailure(self.testcase_pre, sys.exc_info())
     except Exception:
         results.addError(self.testcase_pre, sys.exc_info())
     else:
         results.addSuccess(self.testcase_pre)
     finally:
         return list(iterate_spider_output(cb(response)))
Beispiel #4
0
 def start_requests(self):
     self._postinit_reqs = super(InitSpider, self).start_requests()
     return iterate_spider_output(self.init_request())