forked from discourselab/scrapai-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
72 lines (56 loc) · 1.91 KB
/
Copy pathsettings.py
File metadata and controls
72 lines (56 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Scrapy settings for scrapai_project
import os
import logging
BOT_NAME = "scrapai"
SPIDER_MODULES = ["spiders"]
NEWSPIDER_MODULE = "spiders"
# Obey robots.txt rules
ROBOTSTXT_OBEY = False
# Configure delays for requests
DOWNLOAD_DELAY = 1
RANDOMIZE_DOWNLOAD_DELAY = True
# Configure concurrent requests
CONCURRENT_REQUESTS = 8
CONCURRENT_REQUESTS_PER_DOMAIN = 4
# Enable AutoThrottle
AUTOTHROTTLE_ENABLED = True
AUTOTHROTTLE_START_DELAY = 1
AUTOTHROTTLE_MAX_DELAY = 10
AUTOTHROTTLE_TARGET_CONCURRENCY = 2.0
# User agent (Chrome 145, Feb 2026)
USER_AGENT = (
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36"
)
# Configure item pipelines
ITEM_PIPELINES = {
"pipelines.ScrapaiPipeline": 300,
"pipelines.DatabasePipeline": 400,
}
# Enable smart proxy middleware (only uses proxy on 403/429 errors)
DOWNLOADER_MIDDLEWARES = {
"middlewares.SmartProxyMiddleware": 350,
}
# Spider middlewares
SPIDER_MIDDLEWARES = {
"scrapy_deltafetch.DeltaFetch": 100,
}
# DeltaFetch settings (enabled by default for incremental crawling)
DELTAFETCH_ENABLED = True
DELTAFETCH_DIR = "deltafetch" # DeltaFetch middleware prepends ".scrapy/" automatically
DELTAFETCH_RESET = False
# Cloudflare handler is NOT enabled globally
# Only set when spider has CLOUDFLARE_ENABLED=True in custom_settings
# This prevents conflicts with normal HTTP requests
# Enable and configure HTTP caching
HTTPCACHE_ENABLED = False
HTTPCACHE_EXPIRATION_SECS = 3600
# Set log level to INFO to prevent printing full items with HTML to console
LOG_LEVEL = "INFO"
# Show stats every 10 seconds
LOGSTATS_INTERVAL = 10
# Suppress verbose logs from third-party libraries
logging.getLogger("nodriver").setLevel(logging.WARNING)
logging.getLogger("websockets").setLevel(logging.WARNING)
logging.getLogger("playwright").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)