scrapy之download middleware

官方文档:https://docs.scrapy.org/en/latest/topics/downloader-middleware.html

一 write your own downloader middleware

  process_request(request,spider)

    return:

    1 None

    2 request

    3 response

     4 raise IgnoreRequest

  process_response(request,response,spider)

    return:

    1 response

    2 request

    3 raise IgnoreRequest

  process_exception(request,exception,spider)

    return

    1 None

    2 response

    3 request

  from_crawler(cls,crawler)

    

二 bulit-in downloader middleware

  CookiesMiddleware

  DefaultHeadersMiddleware

  DownloadTimeoutMiddleware

  HttpAuthMiddleware

  HttpCacheMiddleware

  HttpCompressionMiddleware

  HttpProxyMiddleware

  RedirectMiddleware

  MetaRefreshMiddleware

  RetryMiddleware

  RobotsTxtMiddleware

  DownloaderStates

  UserAgentMiddleware

  AjaxCrawlMiddle

posted @ 2018-04-19 22:15  骑者赶路  阅读(131)  评论(0编辑  收藏  举报