crawl_config.json
10.7 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
{
"version": "1.0.0",
"agent": "reddit-scraper",
"updated_at": "2026-04-13T11:30:00+08:00",
"sources": [
{
"id": "reddit_json_hot",
"name": "Reddit Public JSON API - 帖子列表",
"platform": "reddit",
"category": "subreddit_posts",
"url": "https://www.reddit.com/r/{subreddit}/hot.json",
"method": "GET",
"priority": 1,
"enabled": true,
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Accept": "application/json",
"Accept-Language": "en-US,en;q=0.9",
"Connection": "keep-alive"
},
"params": {
"limit": 25,
"after": null
},
"parser": {
"type": "json",
"root_path": "$.data.children",
"item_selector": "*",
"fields": {
"post_id": { "path": "data.id", "type": "string", "required": true },
"title": { "path": "data.title", "type": "string", "required": true },
"author": { "path": "data.author", "type": "string", "required": false },
"subreddit": { "path": "data.subreddit", "type": "string", "required": true },
"permalink": { "path": "data.permalink", "type": "string", "required": true },
"score": { "path": "data.score", "type": "integer", "required": true },
"num_comments": { "path": "data.num_comments", "type": "integer", "required": false, "default": 0 },
"upvote_ratio": { "path": "data.upvote_ratio", "type": "float", "required": false },
"created_utc": { "path": "data.created_utc", "type": "float", "required": false },
"selftext": { "path": "data.selftext", "type": "string", "required": false, "default": "" },
"post_type": { "path": "data.post_hint", "type": "string", "required": false },
"is_nsfw": { "path": "data.over_18", "type": "boolean", "required": false, "default": false },
"is_spoiler": { "path": "data.spoiler", "type": "boolean", "required": false, "default": false },
"awards": { "path": "data.total_awards_received", "type": "integer", "required": false, "default": 0 },
"flair": { "path": "data.link_flair_text", "type": "string", "required": false }
},
"filters": {
"valid_title": "item.title != null && item.title.length > 0",
"not_nsfw": "item.is_nsfw != true"
}
},
"notes": "公开 JSON API,无需 OAuth。支持 sort=hot/new/top/rising/controversial。"
},
{
"id": "reddit_json_comments",
"name": "Reddit Public JSON API - 帖子详情+评论",
"platform": "reddit",
"category": "comments",
"url": "https://www.reddit.com/r/{subreddit}/comments/{post_id}.json",
"method": "GET",
"priority": 2,
"enabled": true,
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Accept": "application/json",
"Accept-Language": "en-US,en;q=0.9"
},
"params": {
"limit": 100,
"sort": "top"
},
"parser": {
"type": "json",
"root_path": "$[1].data.children",
"item_selector": "*",
"fields": {
"comment_id": { "path": "data.id", "type": "string", "required": true },
"author": { "path": "data.author", "type": "string", "required": false },
"body": { "path": "data.body", "type": "string", "required": true },
"score": { "path": "data.score", "type": "integer", "required": false, "default": 0 },
"parent_id": { "path": "data.parent_id", "type": "string", "required": false },
"created_utc": { "path": "data.created_utc", "type": "float", "required": false }
}
},
"notes": "返回数组 [post, comments]。more 节点需递归展开。"
},
{
"id": "reddit_json_search",
"name": "Reddit Public JSON API - 搜索",
"platform": "reddit",
"category": "search",
"url": "https://www.reddit.com/r/{subreddit}/search.json",
"method": "GET",
"priority": 3,
"enabled": true,
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Accept": "application/json"
},
"params": {
"q": "",
"restrict_sr": "1",
"sort": "relevance",
"t": "week",
"limit": 25
},
"parser": {
"type": "json",
"root_path": "$.data.children",
"item_selector": "*",
"fields": {
"post_id": { "path": "data.id", "type": "string", "required": true },
"title": { "path": "data.title", "type": "string", "required": true },
"score": { "path": "data.score", "type": "integer", "required": true },
"subreddit": { "path": "data.subreddit", "type": "string", "required": true }
}
},
"notes": "restricted_sr=1 限制在指定 subreddit 内搜索。"
},
{
"id": "reddit_rss",
"name": "Reddit RSS Feed - 帖子流",
"platform": "reddit",
"category": "rss",
"url": "https://www.reddit.com/r/{subreddit}/.rss",
"method": "GET",
"priority": 4,
"enabled": true,
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Accept": "application/rss+xml,application/xml;q=0.9,*/*;q=0.8"
},
"parser": {
"type": "xml",
"root_path": "//channel/item",
"item_selector": "*",
"fields": {
"title": { "path": "title/text()", "type": "string", "required": true },
"link": { "path": "link/text()", "type": "string", "required": true },
"pubDate": { "path": "pubDate/text()", "type": "string", "required": false },
"author": { "path": "author/text()", "type": "string", "required": false }
}
},
"notes": "RSS 稳定性高但字段较少,适合长期监控的降级方案。"
},
{
"id": "old_reddit_html",
"name": "Old Reddit HTML - 无 JS 页面解析",
"platform": "reddit",
"category": "html_fallback",
"url": "https://old.reddit.com/r/{subreddit}/",
"method": "GET",
"priority": 5,
"enabled": true,
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
"parser": {
"type": "html",
"item_selector": "div.thing",
"fields": {
"post_id": { "selector": "[data-fullname]", "type": "string", "required": true, "attr": "data-fullname" },
"title": { "selector": "a.title", "type": "string", "required": true, "attr": "text" },
"permalink": { "selector": "a.title", "type": "string", "required": false, "attr": "href" },
"score": { "selector": "div.score.unvoted", "type": "string", "required": false, "attr": "text" },
"subreddit": { "selector": "a.subreddit", "type": "string", "required": false, "attr": "text" }
}
},
"notes": "当 JSON API 被封时的最终降级方案,页面轻量、无需 JS。"
},
{
"id": "pushshift_pullpush",
"name": "PullPush API (Pushshift 替代)",
"platform": "reddit",
"category": "historical",
"url": "https://api.pullpush.io/reddit/search/submission/",
"method": "GET",
"priority": 6,
"enabled": false,
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Accept": "application/json"
},
"params": {
"subreddit": "AmITheAsshole",
"size": 25,
"sort": "desc",
"sort_type": "created_utc"
},
"parser": {
"type": "json",
"root_path": "$.data",
"item_selector": "*",
"fields": {
"post_id": { "path": "id", "type": "string", "required": true },
"title": { "path": "title", "type": "string", "required": true },
"author": { "path": "author", "type": "string", "required": false },
"score": { "path": "score", "type": "integer", "required": false },
"created_utc": { "path": "created_utc", "type": "float", "required": false }
}
},
"notes": "Pushshift 的社区替代接口,历史数据可用,当前新数据收录不稳定,默认关闭。"
}
],
"rate_limit": {
"strategy": "adaptive",
"min_delay_seconds": 2,
"max_delay_seconds": 5,
"requests_per_minute": 20,
"cooldown_minutes": 1,
"retry_on_rate_limit": {
"enabled": true,
"max_retries": 3,
"backoff_seconds": 15
}
},
"user_agent_pool": [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148 Safari/604.1",
"Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Mobile Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15"
],
"target_subreddits": [
{ "name": "AmITheAsshole", "priority": 1, "min_score": 2000, "content_type": "moral_dilemma" },
{ "name": "relationship_advice", "priority": 2, "min_score": 1500, "content_type": "trust_issue" },
{ "name": "funny", "priority": 3, "min_score": 5000, "content_type": "observational_humor" },
{ "name": "tifu", "priority": 4, "min_score": 3000, "content_type": "social_conflict" }
],
"validation": {
"expected_content_type": "application/json",
"fallback_content_types": ["text/html", "application/rss+xml"],
"success_indicator": {
"path": "$.kind",
"value": "Listing"
},
"block_indicators": [
"whoa there, pardner",
"blocked due to a network policy"
]
},
"output": {
"schema": "reddit_scraper_v1",
"required_fields": [
"post_id",
"source.platform",
"source.subreddit",
"content.title",
"engagement.score",
"source.source_url",
"source.crawl_time"
],
"include_raw_data": true
},
"compliance": {
"robots_txt": "https://www.reddit.com/robots.txt",
"crawl_delay_seconds": 2,
"exclude_private_data": true,
"exclude_nsfw": true,
"data_retention_days": 90
}
}