【问题标题】:How can I use Scrapy to download all my Quora answers?如何使用 Scrapy 下载我所有的 Quora 答案?
【发布时间】:2017-10-05 21:19:21
【问题描述】:

我正在尝试使用 Scrapy 下载我的 Quora 答案,但我什至似乎无法下载我的页面。使用简单

scrapy shell 'http://it.quora.com/profile/Ferdinando-Randisi'

返回此错误

2017-10-05 22:16:52 [scrapy.utils.log] INFO: Scrapy 1.4.0 started (bot: quora)
2017-10-05 22:16:52 [scrapy.utils.log] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'quora.spiders', 'ROBOTSTXT_OBEY': True, 'DUPEFILTER_CLASS': 'scrapy.dupefilters.BaseDupeFilter', 'SPIDER_MODULES': \[quora.spiders'], 'BOT_NAME': 'quora', 'LOGSTATS_INTERVAL': 0}
....
2017-10-05 22:16:53 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2017-10-05 22:16:53 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
2017-10-05 22:16:53 [scrapy.core.engine] INFO: Spider opened
2017-10-05 22:16:54 [scrapy.downloadermiddlewares.redirect] DEBUG: Redirecting (301) to <GET https://it.quora.com/robots.txt> from <GET http://it.quora.com/robots.txt>
2017-10-05 22:16:55 [scrapy.core.engine] DEBUG: Crawled (429) <GET https://it.quora.com/robots.txt> (referer: None)
2017-10-05 22:16:55 [scrapy.downloadermiddlewares.redirect] DEBUG: Redirecting (301) to <GET https://it.quora.com/profile/Ferdinando-Randisi> from <GET http://it.quora.com/profile/Ferdinando-Randisi>
2017-10-05 22:16:56 [scrapy.core.engine] DEBUG: Crawled (429) <GET https://it.quora.com/profile/Ferdinando-Randisi> (referer: None)
2017-10-05 22:16:58 [root] DEBUG: Using default logger

怎么了?错误 429 与太多请求相关联,但我只发出 一个 请求。为什么会太多?

【问题讨论】:

  • 阅读他们的robots.txt
  • 我做了,但没有看到任何太相关的内容 - 他们只写了如果你使用搜索引擎应该如何让他们知道,他们解释了为什么他们不喜欢人们下载每个人的内容。我没有做这两件事,我只是想要我的答案。
  • 试试curl看看会发生什么。
  • 什么是卷曲?我该如何使用它?对不起,我刚开始刮,所有这些对我来说都很新,我不太了解。
  • 确实很奇怪!我确实看到了这些页面,但我也看到了 curl 编程语言、用于 R 的 curl 网络浏览器、curl 支付系统、Wolfram Alpha 中的 curl 命令。谷歌的搜索结果似乎比人们想象的要多样化。事后看来,curl 实际上与问题并不是很相关,因为它是一个单独的工具,而我的问题是关于 scrapy。不过非常感谢您愿意提供帮助。

标签: web-scraping scrapy quora


【解决方案1】:

它根据用户代理字符串阻止 Scrapy。尝试模仿例如铬:

scrapy shell "http://it.quora.com/profile/Ferdinando-Randisi" -s USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36"

【讨论】:

    猜你喜欢
    • 2016-08-17
    • 2016-01-27
    • 1970-01-01
    • 1970-01-01
    • 2018-01-25
    • 2020-11-12
    • 1970-01-01
    • 1970-01-01
    • 2015-07-19
    相关资源
    最近更新 更多