zoukankan      html  css  js  c++  java
  • Python之Scrapy遇见个坑

    运行Scrapy爬虫被限制抓取,报错:

    2018-01-08 18:37:14 [scrapy.middleware] INFO: Enabled item pipelines:
    []
    2018-01-08 18:37:14 [scrapy.core.engine] INFO: Spider opened
    2018-01-08 18:37:14 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
    2018-01-08 18:37:14 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
    2018-01-08 18:37:23 [scrapy.core.engine] DEBUG: Crawled (403) <GET https://accounts.douban.com/login> (referer: None)
    2018-01-08 18:37:23 [scrapy.spidermiddlewares.httperror] INFO: Ignoring response <403 https://accounts.douban.com/login>: HTTP status code is not handled or not allowed
    2018-01-08 18:37:23 [scrapy.core.engine] INFO: Closing spider (finished)
    2018-01-08 18:37:23 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
    {'downloader/request_bytes': 222,

    解决方法:

    settings.py中添加用户代理

    USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.54 Safari/536.5' 

    搞定。。。

  • 相关阅读:
    Type Safety and Type Inference
    LEARN SWIFT
    swift 类型备份
    Swift
    associatedtype关联类型
    深入理解 Swift 派发机制
    Swift中self和Self
    Postfix Self Expression
    CGContext与上下文
    eeee
  • 原文地址:https://www.cnblogs.com/pyyu/p/8244213.html
Copyright © 2011-2022 走看看