当前位置: 首页>>代码示例>>Python>>正文


Python response.response_status_message方法代码示例

本文整理汇总了Python中scrapy.utils.response.response_status_message方法的典型用法代码示例。如果您正苦于以下问题:Python response.response_status_message方法的具体用法?Python response.response_status_message怎么用?Python response.response_status_message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scrapy.utils.response的用法示例。


在下文中一共展示了response.response_status_message方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_response

# 需要导入模块: from scrapy.utils import response [as 别名]
# 或者: from scrapy.utils.response import response_status_message [as 别名]
def process_response(self, request, response, spider):
        if response.status in [300, 301, 302, 303]:
            try:
                redirect_url = response.headers["location"]
                if "login.weibo" in redirect_url or "login.sina" in redirect_url:  # Cookie失效
                    logger.warning("One Cookie need to be updating...")
                    update_cookie(request.meta['accountText'], self.rconn, spider.name)
                elif "weibo.cn/security" in redirect_url:  # 账号被限
                    logger.warning("One Account is locked! Remove it!")
                    remove_cookie(request.meta["accountText"], self.rconn, spider.name)
                elif "weibo.cn/pub" in redirect_url:
                    logger.warning(
                        "Redirect to 'http://weibo.cn/pub'!( Account:%s )" % request.meta["accountText"].split("--")[0])
                reason = response_status_message(response.status)
                return self._retry(request, reason, spider) or response  # 重试
            except Exception, e:
                logging.warning(e.message)
                raise IgnoreRequest 
开发者ID:wen-fei,项目名称:SinaWeiboSpider,代码行数:20,代码来源:middlewares.py

示例2: process_response

# 需要导入模块: from scrapy.utils import response [as 别名]
# 或者: from scrapy.utils.response import response_status_message [as 别名]
def process_response(self, request, response, spider):
        if request.meta.get('dont_retry', False):
            return response

        if response.status in self.retry_http_codes:
            reason = response_status_message(response.status)
            request.headers['User-Agent'] = self.get_ua()
            return self._retry(request, reason, spider) or response

        return response 
开发者ID:alecxe,项目名称:scrapy-fake-useragent,代码行数:12,代码来源:middleware.py

示例3: process_response

# 需要导入模块: from scrapy.utils import response [as 别名]
# 或者: from scrapy.utils.response import response_status_message [as 别名]
def process_response(self, request, response, spider):
        if response.status in self.retry_http_codes:
            reason = response_status_message(response.status)
            # 删除该代理
            self.delete_proxy(request.meta.get('proxy', False))
            print('返回值异常, 进行重试...')
            return self._retry(request, reason, spider) or response
        return response 
开发者ID:SpiderClub,项目名称:haipproxy,代码行数:10,代码来源:scrapy_middleware.py

示例4: process_response

# 需要导入模块: from scrapy.utils import response [as 别名]
# 或者: from scrapy.utils.response import response_status_message [as 别名]
def process_response(self, request, response, spider):
        if request.meta.get('dont_retry', False):
            return response

        if response.status in self.retry_http_codes:
            reason = response_status_message(response.status)
            return self._retry(request, reason, spider) or response
        return response 
开发者ID:awolfly9,项目名称:jd_analysis,代码行数:10,代码来源:middlewares.py

示例5: process_response

# 需要导入模块: from scrapy.utils import response [as 别名]
# 或者: from scrapy.utils.response import response_status_message [as 别名]
def process_response(self, request, response, spider):
        if request.meta.get('dont_retry', False):
            return response
        if response.status in self.retry_http_codes:
            reason = response_status_message(response.status)
            return self._retry(request, reason, spider) or response
        return response 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:9,代码来源:retry.py

示例6: process_response

# 需要导入模块: from scrapy.utils import response [as 别名]
# 或者: from scrapy.utils.response import response_status_message [as 别名]
def process_response(self, request, response, spider):
        if request.meta.get('dont_retry', False):
            return response
        logging.info("response.status:" + str(response.status))
        if response.status in self.retry_http_codes:
            reason = response_status_message(response.status)
            self.delete_proxy(request.meta.get('proxy', False))
            time.sleep(random.randint(10, 12))
            self.logger.warning('返回值异常, 进行重试...')
            return self._retry(request, reason, spider) or response
        return response 
开发者ID:yhongm,项目名称:lgcrawl,代码行数:13,代码来源:middlewares.py


注:本文中的scrapy.utils.response.response_status_message方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。