當前位置: 首頁>>代碼示例>>Python>>正文


Python reqser.request_from_dict方法代碼示例

本文整理匯總了Python中scrapy.utils.reqser.request_from_dict方法的典型用法代碼示例。如果您正苦於以下問題:Python reqser.request_from_dict方法的具體用法?Python reqser.request_from_dict怎麽用?Python reqser.request_from_dict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scrapy.utils.reqser的用法示例。


在下文中一共展示了reqser.request_from_dict方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: response_from_dict

# 需要導入模塊: from scrapy.utils import reqser [as 別名]
# 或者: from scrapy.utils.reqser import request_from_dict [as 別名]
def response_from_dict(responsed):
    respcls = load_object(responsed['cls'])

    request = request_from_dict(responsed['request'])

    response = respcls(
        encoding=responsed['encoding'],
        request=request,
        url=responsed['url'],
        status=responsed['status'],
        headers=responsed['headers'],
        body=responsed['body'],
    )

    response.meta.update(responsed['meta'])

    return response 
開發者ID:fabienvauchelles,項目名稱:frontoxy,代碼行數:19,代碼來源:utils.py

示例2: _decode_request

# 需要導入模塊: from scrapy.utils import reqser [as 別名]
# 或者: from scrapy.utils.reqser import request_from_dict [as 別名]
def _decode_request(self, encoded_request):
        """Decode an request previously encoded"""
        return request_from_dict(pickle.loads(encoded_request), self.spider) 
開發者ID:onecer,項目名稱:sbdspider,代碼行數:5,代碼來源:queue.py

示例3: _decode_request

# 需要導入模塊: from scrapy.utils import reqser [as 別名]
# 或者: from scrapy.utils.reqser import request_from_dict [as 別名]
def _decode_request(self, encoded_request):
        """Decode a request previously encoded"""
        return request_from_dict(pickle.loads(encoded_request), self.spider) 
開發者ID:rdcprojects,項目名稱:scrapy-mq-redis,代碼行數:5,代碼來源:queue.py

示例4: process_response

# 需要導入模塊: from scrapy.utils import reqser [as 別名]
# 或者: from scrapy.utils.reqser import request_from_dict [as 別名]
def process_response(self, request, response, spider):
        """ If we were logged out, login again and retry request.
        """
        if request.meta.get('_autologin') and self.is_logout(response):
            autologin_meta = request.meta['_autologin']
            if isinstance(autologin_meta['request'], dict):
                retryreq = request_from_dict(autologin_meta['request'], spider)
            else:
                retryreq = autologin_meta['request'].copy()
            retryreq.dont_filter = True
            logger.debug(
                'Logout at %s: %s', retryreq.url, _response_cookies(response))
            if self.logged_in:
                # We could have already done relogin after initial logout
                if any(autologin_meta['cookie_dict'].get(c['name']) !=
                        c['value'] for c in self.auth_cookies):
                    logger.debug('Request was stale, will retry %s', retryreq)
                else:
                    self.logged_in = False
                    # It's better to re-login straight away
                    yield self._ensure_login(retryreq, spider)
                    logout_count = retryreq.meta['autologin_logout_count'] = (
                        retryreq.meta.get('autologin_logout_count', 0) + 1)
                    if logout_count >= self.max_logout_count:
                        logger.debug('Max logouts exceeded, will not retry %s',
                                     retryreq)
                        raise IgnoreRequest
                    else:
                        logger.debug(
                            'Request caused log out (%d), still retrying %s',
                            logout_count, retryreq)
            returnValue(retryreq)
        returnValue(response) 
開發者ID:TeamHG-Memex,項目名稱:autologin-middleware,代碼行數:35,代碼來源:middleware.py

示例5: get_next_request

# 需要導入模塊: from scrapy.utils import reqser [as 別名]
# 或者: from scrapy.utils.reqser import request_from_dict [as 別名]
def get_next_request(self):
        reqd = self._queue_requests.get()
        if not reqd:
            return

        return request_from_dict(reqd, self._spider) 
開發者ID:fabienvauchelles,項目名稱:frontoxy,代碼行數:8,代碼來源:queue.py

示例6: _decode_request

# 需要導入模塊: from scrapy.utils import reqser [as 別名]
# 或者: from scrapy.utils.reqser import request_from_dict [as 別名]
def _decode_request(self, encoded_request):
        """Decode an request previously encoded"""
        obj = self.serializer.loads(encoded_request)
        return request_from_dict(obj, self.spider) 
開發者ID:Python3WebSpider,項目名稱:ScrapyRedisBloomFilter,代碼行數:6,代碼來源:queue.py

示例7: _decode_request

# 需要導入模塊: from scrapy.utils import reqser [as 別名]
# 或者: from scrapy.utils.reqser import request_from_dict [as 別名]
def _decode_request(self, encoded_request):
        return request_from_dict(pickle.loads(encoded_request), self.spider) 
開發者ID:aaldaber,項目名稱:Distributed-Multi-User-Scrapy-System-with-a-Web-UI,代碼行數:4,代碼來源:queue.py


注:本文中的scrapy.utils.reqser.request_from_dict方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。