Я настроил прокси, используя scrapoxy Я пытался установить очень консервативные настройки, не так часто поражая цель, следуя подсказкам здесь , хотя я не уверен, что понимаючто это означает
поверните ваш пользовательский агент из пула известных браузеров (посмотрите вокруг Google, чтобы получить их список)
это мойcurrent settings.py
# -*- coding: utf-8 -*-
BOT_NAME = 'mybot'
SPIDER_MODULES = ['ffscraper.spiders']
NEWSPIDER_MODULE = 'ffscraper.spiders'
# Crawl responsibly by identifying yourself (and your website) on the user-agent
USER_AGENT = 'myUnivProject'
# Obey robots.txt rules
ROBOTSTXT_OBEY = False
# Configure maximum concurrent requests performed by Scrapy (default: 16)
CONCURRENT_REQUESTS = 5
# Configure a delay for requests for the same website (default: 0)
# See https://doc.scrapy.org/en/latest/topics/settings.html#download-delay
# See also autothrottle settings and docs
DOWNLOAD_DELAY = 20.0
# The download delay setting will honor only one of:
#CONCURRENT_REQUESTS_PER_DOMAIN = 1
CONCURRENT_REQUESTS_PER_IP = 1
DOWNLOAD_TIMEOUT = 30
RETRY_TIMES = 0
# PROXY
PROXY = 'http://xxx.xxx.xxx.x:8888/?noconnect'
# SCRAPOXY
API_SCRAPOXY = 'http://xxx.xxx.xxx.x:8889/api'
API_SCRAPOXY_PASSWORD = 'xxxx'
DOWNLOADER_MIDDLEWARES = {
'scrapoxy.downloadmiddlewares.proxy.ProxyMiddleware': 100,
'scrapoxy.downloadmiddlewares.wait.WaitMiddleware': 101,
'scrapoxy.downloadmiddlewares.scale.ScaleMiddleware': 102,
'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': None,
}
# Disable cookies (enabled by default)
COOKIES_ENABLED = False
# Disable Telnet Console (enabled by default)
#TELNETCONSOLE_ENABLED = False
# Override the default request headers:
#DEFAULT_REQUEST_HEADERS = {
# 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
# 'Accept-Language': 'en',
#}
# Enable or disable spider middlewares
# See https://doc.scrapy.org/en/latest/topics/spider-middleware.html
#SPIDER_MIDDLEWARES = {
# 'ffscraper.middlewares.FfscraperSpiderMiddleware': 543,
#}
# Enable or disable downloader middlewares
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html
#DOWNLOADER_MIDDLEWARES = {
# 'ffscraper.middlewares.FfscraperDownloaderMiddleware': 543,
#}
# Enable or disable extensions
# See https://doc.scrapy.org/en/latest/topics/extensions.html
#EXTENSIONS = {
# 'scrapy.extensions.telnet.TelnetConsole': None,
#}
# Configure item pipelines
# See https://doc.scrapy.org/en/latest/topics/item-pipeline.html
#ITEM_PIPELINES = {
# 'ffscraper.pipelines.FfscraperPipeline': 300,
#}
# Enable and configure the AutoThrottle extension (disabled by default)
# See https://doc.scrapy.org/en/latest/topics/autothrottle.html
AUTOTHROTTLE_ENABLED = True
# The initial download delay
AUTOTHROTTLE_START_DELAY = 5
# The maximum download delay to be set in case of high latencies
AUTOTHROTTLE_MAX_DELAY = 60
# The average number of requests Scrapy should be sending in parallel to
# each remote server
#AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
# Enable showing throttling stats for every response received:
#AUTOTHROTTLE_DEBUG = False
# Enable and configure HTTP caching (disabled by default)
# See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
#HTTPCACHE_ENABLED = True
#HTTPCACHE_EXPIRATION_SECS = 0
#HTTPCACHE_DIR = 'httpcache'
#HTTPCACHE_IGNORE_HTTP_CODES = []
#HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'
Я все еще, только после ~ 50 или около того запросов, начинаю перенаправлять на страницу с капчей.
2019-01-04 00:17:09 [scrapy.downloadermiddlewares.redirect] DEBUG: Redirecting (meta refresh) to <GET https://www.asite.com/distil_r_captcha.html?requestId=xxx-xxx-xxx-xxx-xxx&httpReferrer=xxxx> from <GET https://www.asite.com/xxx/xxx>
Блокировка перенаправления как в здесь не вариант.Мне нужно было бы иметь возможность возобновить деятельность.В настоящее время единственное, что я могу сделать, это остановить гусеничный механизм, убить виртуальные машины на скрапокси и перезапустить скребок.
- Я скучаю по слону в комнате?Есть ли что-то, что я мог бы изменить в моих настройках?
- В качестве альтернативы, есть ли способ программно завершить работу виртуальной машины и воссоздать ее при перенаправлении?
Что интересно, если яперенаправление блока
yield scrapy.Request(
url="https://www.whatasite.com" + url.split("?")[0],
meta={"name": name, 'dont_redirect': True,},
callback=self.parse
)
Затем я получаю 200
и страницу, которую не могу почистить (получая поэтому пустые значения), вместо того, чтобы захватить код ошибки, который я мог бы обработать, как в здесь .