settings.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Scrapy settings for nmc project
  2. #
  3. # For simplicity, this file contains only settings considered important or
  4. # commonly used. You can find more settings consulting the documentation:
  5. #
  6. # https://docs.scrapy.org/en/latest/topics/settings.html
  7. # https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
  8. # https://docs.scrapy.org/en/latest/topics/spider-middleware.html
  9. BOT_NAME = "nmc"
  10. SPIDER_MODULES = ["nmc.spiders"]
  11. NEWSPIDER_MODULE = "nmc.spiders"
  12. # Crawl responsibly by identifying yourself (and your website) on the user-agent
  13. USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0"
  14. REACTOR = 'twisted.internet.selectreactor.SelectReactor'
  15. LOG_LEVEL = 'DEBUG'
  16. # Obey robots.txt rules
  17. ROBOTSTXT_OBEY = False
  18. # Configure maximum concurrent requests performed by Scrapy (default: 16)
  19. CONCURRENT_REQUESTS = 32
  20. # Configure a delay for requests for the same website (default: 0)
  21. # See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay
  22. # See also autothrottle settings and docs
  23. DOWNLOAD_DELAY = 3
  24. RANDOMIZE_DOWNLOAD_DELAY = True
  25. # The download delay setting will honor only one of:
  26. # CONCURRENT_REQUESTS_PER_DOMAIN = 16
  27. # CONCURRENT_REQUESTS_PER_IP = 16
  28. # Disable cookies (enabled by default)
  29. COOKIES_ENABLED = False
  30. # Disable Telnet Console (enabled by default)
  31. # TELNETCONSOLE_ENABLED = False
  32. # Override the default request headers:
  33. DEFAULT_REQUEST_HEADERS = {
  34. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36',
  35. 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  36. 'Accept-Language': 'en',
  37. }
  38. # Enable or disable spider middlewares
  39. # See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
  40. # SPIDER_MIDDLEWARES = {
  41. # "nmc.middlewares.NmcSpiderMiddleware": 543,
  42. # }
  43. # Enable or disable downloader middlewares
  44. # See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
  45. # DOWNLOADER_MIDDLEWARES = {
  46. # # "nmc.middlewares.NmcDownloaderMiddleware": 543,
  47. # "nmc.middlewares.SeleniumDownloaderMiddleware": 543,
  48. # 'scrapy.downloadermiddlewares.useragent.UseragentMiddleware': None
  49. # }
  50. # Enable or disable extensions
  51. # See https://docs.scrapy.org/en/latest/topics/extensions.html
  52. # EXTENSIONS = {
  53. # "scrapy.extensions.telnet.TelnetConsole": None,
  54. # }
  55. # Configure item pipelines
  56. # See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
  57. ITEM_PIPELINES = {
  58. "nmc.pipelines.NmcPipeline": 300,
  59. }
  60. # Enable and configure the AutoThrottle extension (disabled by default)
  61. # See https://docs.scrapy.org/en/latest/topics/autothrottle.html
  62. # AUTOTHROTTLE_ENABLED = True
  63. # The initial download delay
  64. # AUTOTHROTTLE_START_DELAY = 5
  65. # The maximum download delay to be set in case of high latencies
  66. # AUTOTHROTTLE_MAX_DELAY = 60
  67. # The average number of requests Scrapy should be sending in parallel to
  68. # each remote server
  69. # AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
  70. # Enable showing throttling stats for every response received:
  71. # AUTOTHROTTLE_DEBUG = False
  72. # Enable and configure HTTP caching (disabled by default)
  73. # See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
  74. # HTTPCACHE_ENABLED = True
  75. # HTTPCACHE_EXPIRATION_SECS = 0
  76. # HTTPCACHE_DIR = "httpcache"
  77. # HTTPCACHE_IGNORE_HTTP_CODES = []
  78. # HTTPCACHE_STORAGE = "scrapy.extensions.httpcache.FilesystemCacheStorage"
  79. # Set settings whose default value is deprecated to a future-proof value
  80. REQUEST_FINGERPRINTER_IMPLEMENTATION = "2.7"
  81. TWISTED_REACTOR = "twisted.internet.asyncioreactor.AsyncioSelectorReactor"
  82. FEED_EXPORT_ENCODING = "utf-8"