mixin.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:scrapy-mosquitera 作者: scrapinghub 项目源码 文件源码
def _get_response(self, args=[], kwargs={}):
        """ Get response from ``args`` or ``kwargs``. """
        # If you're decorating a function without response objects as arguments
        # or invalid ones, you can set this attribute that has precedence.
        if hasattr(self, 'response_for_pagination_mixin'):
            return self.response_for_pagination_mixin

        total_args = list(args) + list(kwargs.values())
        response_objs = [obj for obj in total_args if isinstance(obj, Response)]
        n_response_objs = len(response_objs)

        if n_response_objs == 0:
            raise ValueError('No response could be extracted.')
        if n_response_objs == 1:
            return response_objs[0]
        elif n_response_objs > 1:
            logging.warning('[-] Detected more than one response. Using the first one.')
            return response_objs[0]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号