159 lines
6.5 KiB
Python
159 lines
6.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
# Scrapy settings for AirplaneSpiders project
|
|
#
|
|
# For simplicity, this file contains only settings considered important or
|
|
# commonly used. You can find more settings consulting the documentation:
|
|
#
|
|
# https://docs.scrapy.org/en/latest/topics/settings.html
|
|
# https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
|
|
# https://docs.scrapy.org/en/latest/topics/spider-middleware.html
|
|
from shutil import which
|
|
|
|
BOT_NAME = 'AirplaneSpiders'
|
|
|
|
SPIDER_MODULES = ['AirplaneSpiders.spiders']
|
|
NEWSPIDER_MODULE = 'AirplaneSpiders.spiders'
|
|
|
|
SELENIUM_DRIVER_NAME = 'chrome'
|
|
SELENIUM_DRIVER_EXECUTABLE_PATH = 'http://96.45.186.11:25555/wd/hub'
|
|
# SELENIUM_DRIVER_EXECUTABLE_PATH = which('geckodriver')
|
|
SELENIUM_DRIVER_ARGUMENTS = ['-headless'] # '--headless' if using chrome instead of firefox
|
|
|
|
SPLASH_URL = 'http://104.225.146.144:28050'
|
|
|
|
PROXY_SERVICE = 'http://39.101.194.63:6800/'
|
|
# PROXY_SERVICE = 'http://107.182.191.3:6800/'
|
|
PER_BATCH_IP_USE_TIMES = 20
|
|
|
|
KAFKA_SERVER = '47.113.231.200:9092'
|
|
KAFKA_TOPIC = 'stream-protobuf'
|
|
KAFKA_PROCESS_QUEUE = ['stream-protobuf']
|
|
|
|
CRAWL_JOB_UPDATE_API = 'http://47.115.228.133:28081/api/open/crawljob'
|
|
LOG_LEVEL = 'INFO'
|
|
|
|
REDIS_HOST = '107.182.191.3'
|
|
REDIS_PORT = 7379
|
|
REDIS_PWD = 'jlkj-841-2-redis'
|
|
|
|
FILE_TRANS_PATH = r'/usr/local/spider_data'
|
|
|
|
DOWNLOAD_TIMEOUT = 15
|
|
RETENTION_HOURS = 120
|
|
BATCH_SAVE_SIZE = 1000
|
|
# SELENIUM_DRIVER_NAME = 'firefox'
|
|
# SELENIUM_DRIVER_EXECUTABLE_PATH = which('geckodriver')
|
|
# SELENIUM_DRIVER_ARGUMENTS=[] # '--headless' if using chrome instead of firefox '-headless'
|
|
|
|
# Crawl responsibly by identifying yourself (and your website) on the user-agent
|
|
# USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0'
|
|
|
|
# Obey robots.txt rules
|
|
ROBOTSTXT_OBEY = False
|
|
|
|
# Configure maximum concurrent requests performed by Scrapy (default: 16)
|
|
# CONCURRENT_REQUESTS = 16
|
|
|
|
# Configure a delay for requests for the same website (default: 0)
|
|
# See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay
|
|
# See also autothrottle settings and docs
|
|
DOWNLOAD_DELAY = 0.1
|
|
RANDOMIZE_DOWNLOAD_DELAY = True
|
|
# The download delay setting will honor only one of:
|
|
# CONCURRENT_REQUESTS_PER_DOMAIN = 16
|
|
# CONCURRENT_REQUESTS_PER_IP = 16
|
|
|
|
# Disable cookies (enabled by default)
|
|
COOKIES_ENABLED = True
|
|
|
|
# Disable Telnet Console (enabled by default)
|
|
# TELNETCONSOLE_ENABLED = False
|
|
|
|
# Override the default request headers:
|
|
# DEFAULT_REQUEST_HEADERS = {
|
|
# 'Accept': 'application/json, text/plain, */*',
|
|
# 'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
|
|
# 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
|
|
# 'Connection': 'keep-alive',
|
|
# 'Host': 'data.rb24.com',
|
|
# 'Origin': 'https://www.radarbox.com',
|
|
# 'Referer': 'https://www.radarbox.com/@2.41699,27.25463,z3',
|
|
# 'TE': 'Trailers'
|
|
# }
|
|
|
|
CUSTOM_USER_AGENT = [
|
|
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36',
|
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0',
|
|
'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko',
|
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18363',
|
|
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50',
|
|
'Opera/9.80 (Windows NT 6.1; U; zh-cn) Presto/2.9.168 Version/11.50',
|
|
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; SE 2.X MetaSr 1.0',
|
|
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E',
|
|
'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1 QQBrowser/6.9.11079.201'
|
|
]
|
|
|
|
# HEADERS={
|
|
# 'Accept': 'application/json, text/plain, */*',
|
|
# 'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
|
|
# 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
|
|
# 'Connection': 'keep-alive',
|
|
# 'Host': 'data.rb24.com',
|
|
# 'Origin': 'https://www.radarbox.com',
|
|
# 'Referer': 'https://www.radarbox.com/@2.41699,27.25463,z3',
|
|
# 'TE': 'Trailers'
|
|
# }
|
|
|
|
# Enable or disable spider middlewares
|
|
# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
|
|
SPIDER_MIDDLEWARES = {
|
|
'scrapy_splash.SplashDeduplicateArgsMiddleware': 100,
|
|
'AirplaneSpiders.middlewares.DumpFiliterSpiderMiddleware': 103
|
|
}
|
|
|
|
# Enable or disable downloader middlewares
|
|
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
|
|
DOWNLOADER_MIDDLEWARES = {
|
|
# 'AirplaneSpiders.middlewares.MyProxyDownloaderMiddleware': 100,
|
|
'AirplaneSpiders.middlewares.UserAgentDownloaderMiddleware': 101,
|
|
'AirplaneSpiders.middlewares.DumpFilterDownloaderMiddleware': 102,
|
|
'scrapy_splash.SplashCookiesMiddleware': 723,
|
|
'scrapy_splash.SplashMiddleware': 725,
|
|
'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware': 810,
|
|
# 'AirplaneSpiders.scrapy_selenium.SeleniumMiddleware': 820
|
|
}
|
|
|
|
# Enable or disable extensions
|
|
# See https://docs.scrapy.org/en/latest/topics/extensions.html
|
|
EXTENSIONS = {
|
|
'AirplaneSpiders.extensions.SetCrawlerStatusExtensions': 501,
|
|
}
|
|
|
|
# Configure item pipelines
|
|
# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
|
|
ITEM_PIPELINES = {
|
|
'AirplaneSpiders.pipelines.ProtobufSavePipeline': 300
|
|
}
|
|
|
|
# Enable and configure the AutoThrottle extension (disabled by default)
|
|
# See https://docs.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://docs.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'
|