【发布时间】:2017-03-20 17:33:40
【问题描述】:
我正在尝试使用 Scrapy 框架从 LinkedIn 中提取一些信息。 我知道他们对试图爬取他们网站的人非常严格,所以我在我的 settings.py 中尝试了不同的用户代理。我还指定了很高的下载延迟,但它似乎仍然阻止了我。
USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0'
ROBOTSTXT_OBEY = False
DOWNLOAD_DELAY = 2
REDIRECT_ENABLED = False
RETRY_ENABLED = False
DEPTH_LIMIT = 5
DOWNLOAD_TIMEOUT = 10
REACTOR_THREADPOOL_MAXSIZE = 20
CONCURRENT_REQUESTS_PER_DOMAIN = 2
COOKIES_ENABLED = False
HTTPCACHE_ENABLED = True
这是我收到的错误:
2017-03-20 19:11:29 [scrapy.core.engine] INFO: Spider opened
2017-03-20 19:11:29 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min),
scraped 0 items (at 0 items/min)
2017-03-20 19:11:29 [scrapy.extensions.telnet] DEBUG: Telnet console listening on
127.0.0.1:6023
2017-03-20 19:11:29 [scrapy.core.engine] DEBUG: Crawled (999) <GET
https://www.linkedin.com/directory/people-1/> (referer: None) ['cached']
2017-03-20 19:11:29 [scrapy.spidermiddlewares.httperror] INFO: Ignoring response
<999 https://www.linkedin.com/directory/people-1/>: HTTP status code is not handled or
not allowed
2017-03-20 19:11:29 [scrapy.core.engine] INFO: Closing spider (finished)
2017-03-20 19:11:29 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 282,
'downloader/request_count': 1,
'downloader/request_method_count/GET': 1,
'downloader/response_bytes': 2372,
'downloader/response_count': 1,
'downloader/response_status_count/999': 1,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2017, 3, 20, 17, 11, 29, 503000),
'httpcache/hit': 1,
'log_count/DEBUG': 2,
'log_count/INFO': 8,
'response_received_count': 1,
'scheduler/dequeued': 1,
'scheduler/dequeued/memory': 1,
'scheduler/enqueued': 1,
'scheduler/enqueued/memory': 1,
'start_time': datetime.datetime(2017, 3, 20, 17, 11, 29, 378000)}
2017-03-20 19:11:29 [scrapy.core.engine] INFO: Spider closed (finished)
蜘蛛本身只是打印访问过的 url。
class InfoSpider(CrawlSpider):
name = "info"
allowed_domains = ["www.linkedin.com"]
start_urls = ['https://www.linkedin.com/directory/people-1/']
rules = [
Rule(LinkExtractor(
allow=[r'.*']),
callback='parse',
follow=True)
]
def parse(self, response):
print(response.url)
【问题讨论】:
-
问题是什么?
-
你也在抓取个人数据吗?忽略服务条款是一回事 - 我个人认为它们不一定具有约束力 - 但在未经受影响个人许可的情况下获取和重复使用个人数据则是另一回事。
-
感谢您的回复。我不会使用任何数据。我只是在学习 Scrapy,并试图了解它在这样的场景中是如何工作的。
-
你有没有让这个和scrapy一起工作?如果是,您能否更新您的问题并添加解决方案?
标签: python web-scraping scrapy