# Path: config/base_settings.py
# BASE_PATH = os.path.split(os.path.split(__file__)[0])[0]
# OUTPUT_PATH = os.path.join(BASE_PATH, 'output')
# OUTPUT_GROUP_PATH = os.path.join(OUTPUT_PATH, TimeUtil.getFormatTime('%Y%m%d_%H%M%S'))
# DATABASE_NAME = os.path.join(OUTPUT_GROUP_PATH, 'Patent.db')
# EXCEL_NAME = os.path.join(OUTPUT_GROUP_PATH, '专利.xlsx')
# CHARTS_NAME = os.path.join(OUTPUT_GROUP_PATH, 'charts.html')
# LOG_FILENAME = os.path.join(OUTPUT_GROUP_PATH, "PatentCrawler.log")
# CAPTCHA_MODEL_NAME = os.path.join(BASE_PATH, 'res', 'captcha', 'sipo3.job')
# AD_PATH = os.path.join(BASE_PATH, 'res', 'advertisement', 'ad.html')
# USE_PROXY = False
# PROXY_URL = 'http://127.0.0.1:5010/get'
# TIMEOUT = 10
# DOWNLOAD_DELAY = 1
# OUTPUT_ITEMS = ['data', 'log', 'chart']
#         USE_PROXY = use_proxy
#                 PROXY_URL = proxy_url
#             TIMEOUT = timeout
#             DOWNLOAD_DELAY = delay
#             OUTPUT_ITEMS = output_items
# def check_proxy(cfg):
# def check_request(cfg: configparser.ConfigParser):
# def check_output(cfg):


from config import base_settings as bs
# CONCURRENT_REQUESTS_PER_IP = 16

# Disable cookies (enabled by default)
COOKIES_ENABLED = True
COOKIES_DEBUG = True
DUPEFILTER_DEBUG = True
REDIRECT_ENABLED = True

# 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 http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html
# SPIDER_MIDDLEWARES = {
#    'crawler.middlewares.CrawlerSpiderMiddleware': 543,
# }

# Enable or disable downloader middlewares
# See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
    # 'crawler.middlewares.MyCustomDownloaderMiddleware': 543,
    'crawler.middlewares.PatentMiddleware': 544,
    # 'crawler.middlewares.RandomUserAgentMiddleware': 542
}

# Path: config/base_settings.py
# BASE_PATH = os.path.split(os.path.split(__file__)[0])[0]
# OUTPUT_PATH = os.path.join(BASE_PATH, 'output')
# OUTPUT_GROUP_PATH = os.path.join(OUTPUT_PATH, TimeUtil.getFormatTime('%Y%m%d_%H%M%S'))
# DATABASE_NAME = os.path.join(OUTPUT_GROUP_PATH, 'Patent.db')
# EXCEL_NAME = os.path.join(OUTPUT_GROUP_PATH, '专利.xlsx')
# CHARTS_NAME = os.path.join(OUTPUT_GROUP_PATH, 'charts.html')
# LOG_FILENAME = os.path.join(OUTPUT_GROUP_PATH, "PatentCrawler.log")
# CAPTCHA_MODEL_NAME = os.path.join(BASE_PATH, 'res', 'captcha', 'sipo3.job')
# AD_PATH = os.path.join(BASE_PATH, 'res', 'advertisement', 'ad.html')
# USE_PROXY = False
# PROXY_URL = 'http://127.0.0.1:5010/get'
# TIMEOUT = 10
# DOWNLOAD_DELAY = 1
# OUTPUT_ITEMS = ['data', 'log', 'chart']
#         USE_PROXY = use_proxy
#                 PROXY_URL = proxy_url
#             TIMEOUT = timeout
#             DOWNLOAD_DELAY = delay
#             OUTPUT_ITEMS = output_items
# def check_proxy(cfg):
# def check_request(cfg: configparser.ConfigParser):
# def check_output(cfg):


# Path: crawler/settings.py
from config import base_settings as bs

# CONCURRENT_REQUESTS_PER_IP = 16

# Disable cookies (enabled by default)
COOKIES_ENABLED = True
COOKIES_DEBUG = True
DUPEFILTER_DEBUG = True
REDIRECT_ENABLED = True

# 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 http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html
# SPIDER_MIDDLEWARES = {
#    'crawler.middlewares.CrawlerSpiderMiddleware': 543,
# }

# Enable or disable downloader middlewares
# See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
    # 'crawler.middlewares.MyCustomDownloaderMiddleware': 543,
    'crawler.middlewares.PatentMiddleware': 544,
    # 'crawler.middlewares.RandomUserAgentMiddleware': 542
}

DOWNLOAD_TIMEOUT = bs.TIMEOUT