reddrix 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Omar Abdelhamid
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
reddrix-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,341 @@
1
+ Metadata-Version: 2.4
2
+ Name: reddrix
3
+ Version: 0.1.0
4
+ Summary: Reddrix is an open-source, blazing fast Reddit Scraper for Python (No API Key)
5
+ Description-Content-Type: text/markdown
6
+ License-File: LICENSE.md
7
+ Requires-Dist: camoufox[geoip]
8
+ Requires-Dist: whiskeysour
9
+ Requires-Dist: curl-cffi
10
+ Dynamic: description
11
+ Dynamic: description-content-type
12
+ Dynamic: license-file
13
+ Dynamic: requires-dist
14
+ Dynamic: summary
15
+
16
+ <p align="center">
17
+ <img src="https://raw.githubusercontent.com/Coding-Doctor-Omar/reddrix/main/images/reddrix.png" width="350" alt="reddrix logo">
18
+ </p>
19
+
20
+ <p align="center">
21
+ <a href="https://ko-fi.com/CodingDoctorOmar">
22
+ <img src="https://ko-fi.com/img/githubbutton_sm.svg" alt="Support Me on Ko-fi">
23
+ </a>
24
+ </p>
25
+
26
+ # Reddrix &mdash; An open-source, blazing fast Reddit Scraper for Python (No API Key)
27
+
28
+ <p align="center"><h3>A powerful, async-first Reddit scraper (with built-in proxy support) for posts and comments with detailed metrics. No API key required. Scrape subreddits, profiles, and specific posts, or search Reddit site-wide by keywords or domains. Collect rich, structured data including authors, scores, timestamps, flairs, comment threads, and more (30+ fields).</h3></p>
29
+
30
+ > If this repo is useful to you or saved your time, consider starring ⭐ it to support me and help other find it and have an easier time scraping Reddit ❤️.
31
+
32
+ > Need a hosted version, check [Reddit Scraper Pro](https://apify.com/coding-doctor-omar/Reddit-Scraper-Pro) on Apify.
33
+
34
+ <p align="center">
35
+ <a href="#installation">Installation</a> • <a href="#quick-start">Quick Start</a> • <a href="#output-dataset">Output Dataset</a> •
36
+ <a href="#features">Features</a> • <a href="#scraper-options">Scraper Options</a>
37
+ </p>
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install reddrix
43
+
44
+ reddrix install # Optional for installing Camoufox if you want to use Reddrix with Camoufox
45
+ ```
46
+
47
+ ## Quick start
48
+
49
+ **Using Async Context Manager:**
50
+
51
+ ```python
52
+ from reddrix import Reddrix
53
+ import asyncio
54
+
55
+ async def main():
56
+ async with Reddrix(
57
+ mode="standard",
58
+ subreddit_urls=["https://www.reddit.com/r/webscraping"],
59
+ sort="new",
60
+ include_comments=True,
61
+ max_results=500,
62
+ max_posts_per_collection=500,
63
+ verbose=True
64
+ ) as reddrix:
65
+ async for item in reddrix.get_items():
66
+ print(item["submissionType"], item["submissionUrl"])
67
+
68
+ if __name__ == "__main__":
69
+ asyncio.run(main())
70
+ ```
71
+
72
+ **Without the context manager:**
73
+
74
+ ```python
75
+ from reddrix import Reddrix
76
+ import asyncio
77
+
78
+ async def main():
79
+ reddrix = Reddrix(
80
+ mode="standard",
81
+ subreddit_urls=["https://www.reddit.com/r/webscraping"],
82
+ sort="new",
83
+ include_comments=True,
84
+ max_results=500,
85
+ max_posts_per_collection=500,
86
+ proxies=["http://user:pass@hostname:port", "http://user2:pass2@hostname2:port2"], # Built-in automatic proxy rotation
87
+ verbose=True
88
+ )
89
+ await reddrix.start()
90
+
91
+ async for item in reddrix.get_items():
92
+ print(item["submissionType"], item["submissionUrl"])
93
+
94
+ await reddrix.stop()
95
+
96
+
97
+ if __name__ == "__main__":
98
+ asyncio.run(main())
99
+ ```
100
+
101
+ **Scraping Posts and Comments Based on Keywords:**
102
+
103
+ ```python
104
+ from reddrix import Reddrix
105
+ import asyncio
106
+
107
+ async def main():
108
+ async with Reddrix(
109
+ mode="keyword_search",
110
+ sort="new", # The sort option is ignored for this mode
111
+ query="how to scrape reddit",
112
+ include_comments=True,
113
+ max_results=500,
114
+ max_posts_per_collection=500,
115
+ verbose=True
116
+ ) as reddrix:
117
+ async for item in reddrix.get_items():
118
+ print(item["submissionType"], item["submissionUrl"])
119
+
120
+ if __name__ == "__main__":
121
+ asyncio.run(main())
122
+ ```
123
+
124
+ **Scraping Posts and Comments Based on Domains:**
125
+
126
+ ```python
127
+ from reddrix import Reddrix
128
+ import asyncio
129
+
130
+ async def main():
131
+ async with Reddrix(
132
+ mode="domain_search",
133
+ sort="new",
134
+ domains=["github.com", "apify.com"],
135
+ include_comments=True,
136
+ max_results=500,
137
+ max_posts_per_collection=500,
138
+ verbose=True
139
+ ) as reddrix:
140
+ async for item in reddrix.get_items():
141
+ print(item["submissionType"], item["submissionUrl"])
142
+
143
+ if __name__ == "__main__":
144
+ asyncio.run(main())
145
+ ```
146
+
147
+
148
+
149
+ **Using Reddrix as a standalone Reddit http client for your custom scraping setup:**
150
+
151
+ ```python
152
+ from reddrix import Reddrix
153
+ import asyncio
154
+
155
+ async def main():
156
+ async with Reddrix() as reddrix:
157
+ json_data = await reddrix.get("https://www.reddit.com/r/webscraping.json")
158
+ html_content = await reddrix.get(
159
+ url="https://www.reddit.com/search?q=how+to+scrape+reddit",
160
+ expected_data_type="HTML/XML" # You must specify the data type if you want to fetch html or xml.
161
+ )
162
+
163
+ if __name__ == "__main__":
164
+ asyncio.run(main())
165
+ ```
166
+
167
+ **Using Reddrix with Camoufox:**
168
+
169
+ ```bash
170
+ pip install reddrix
171
+ reddrix install # Installs the camoufox browser
172
+ ```
173
+
174
+ ```python
175
+ from reddrix import Reddrix
176
+ import asyncio
177
+
178
+ async def main():
179
+ async with Reddrix(
180
+ mode="standard",
181
+ http_client="camoufox", # By default, the http_client is "curl_cffi", but you can choose Camoufox.
182
+ subreddit_urls=["https://www.reddit.com/r/webscraping"],
183
+ sort="new",
184
+ include_comments=True,
185
+ max_results=500,
186
+ max_posts_per_collection=500,
187
+ verbose=True
188
+ ) as reddrix:
189
+ async for item in reddrix.get_items():
190
+ print(item["submissionType"], item["submissionUrl"])
191
+
192
+ if __name__ == "__main__":
193
+ asyncio.run(main())
194
+ ```
195
+
196
+ This option is included in anticipation of future aggressive anti-scraping measures from Reddit. Even when Camoufox is used as the http client, the scraper uses it intelligently. It still utilizes the same JSON endpoints that curl_cffi uses via `page.evaluate()` with JS fetch. This results in nearly the same scraping speed, but with more stealth. The only caveat is more resource usage and slower scraper initialization speed.
197
+
198
+ ## Output Dataset
199
+
200
+ If you use the preset scraping setup from `reddrix.get_items()`, the output dataset is a Python dictionary.
201
+
202
+ **Example Reddit Post Output:**
203
+
204
+ ```python
205
+ {
206
+ "submissionId": "1w1gc8p",
207
+ "submissionIdPrefixed": "t3_1w1gc8p",
208
+ "submissionType": "post",
209
+ "submissionUrl": "https://www.reddit.com/r/Sat/comments/1w1gc8p/is_this_good_improvement_for_10_hours_of/",
210
+ "submittedAt": "2026-08-29T07:53:42+00:00",
211
+ "parentId": None,
212
+ "parentPostId": None,
213
+ "parentPostUrl": None,
214
+ "postType": "image",
215
+ "isCrosspost": False,
216
+ "crosspostParentId": None,
217
+ "crosspostParentUrl": None,
218
+ "title": "Is this good improvement for 10 hours of dedicated study + need help for rw section",
219
+ "bodyText": "math significantly improved but reading writing is too tough for me (international student)\n\nplease help, i have to give the sat in two months, will reading novels improve my rw score?",
220
+ "isEdited": False,
221
+ "author": "stcer",
222
+ "authorFlairText": None,
223
+ "authorFlairImageUrl": None,
224
+ "depth": None,
225
+ "postFlair": None,
226
+ "isNSFW": False,
227
+ "subreddit": "r/Sat",
228
+ "score": 32,
229
+ "upvoteRatio": 0.98,
230
+ "numComments": 29,
231
+ "numCrossposts": 0,
232
+ "externalUrl": "https://i.redd.it/cjhezz5bs9mh1.jpeg",
233
+ "thumbnailUrl": None,
234
+ "videoUrl": None,
235
+ "imageUrl": "https://i.redd.it/cjhezz5bs9mh1.jpeg",
236
+ "galleryImagesUrls": None
237
+ }
238
+ ```
239
+
240
+ **Example Comment Output:**
241
+
242
+ ```python
243
+ {
244
+ "submissionId": "p6lwobb",
245
+ "submissionIdPrefixed": "t1_p6lwobb",
246
+ "submissionType": "comment",
247
+ "submissionUrl": "https://www.reddit.com/r/Sat/comments/1w1gc8p/is_this_good_improvement_for_10_hours_of/p6lwobb/",
248
+ "submittedAt": "2026-08-29T13:41:52+00:00",
249
+ "parentId": "t3_1w1gc8p",
250
+ "parentPostId": "t3_1w1gc8p",
251
+ "parentPostUrl": "https://www.reddit.com/r/Sat/comments/1w1gc8p",
252
+ "postType": None,
253
+ "isCrosspost": False,
254
+ "crosspostParentId": None,
255
+ "crosspostParentUrl": None,
256
+ "title": None,
257
+ "bodyText": "How did you do that in 10 hours? Can you please give me the sources that you used? I also need help in rw section and I’ll take the sat in 2 weeks",
258
+ "isEdited": False,
259
+ "author": "AnalysisStill4932",
260
+ "authorFlairText": None,
261
+ "authorFlairImageUrl": None,
262
+ "depth": 0,
263
+ "postFlair": None,
264
+ "isNSFW": False,
265
+ "subreddit": "r/Sat",
266
+ "score": 9,
267
+ "upvoteRatio": None,
268
+ "numComments": None,
269
+ "numCrossposts": None,
270
+ "externalUrl": None,
271
+ "thumbnailUrl": None,
272
+ "videoUrl": None,
273
+ "imageUrl": None,
274
+ "galleryImagesUrls": None
275
+ }
276
+ ```
277
+ **Output Fields Explanation:**
278
+
279
+ 1. `submissionId` &mdash; [`string`] The ID of the post or comment.
280
+ 2. `submissionIdPrefixed` &mdash; [`string`] The prefixed ID of the post or comment.
281
+ 3. `submissionType` &mdash; [`string`] Whether the submission is a `post` or `comment`.
282
+ 4. `submissionUrl` &mdash; [`string`] The URL for the submission.
283
+ 5. `submittedAt` &mdash; [`string`] The date and time the post or comment was submitted in UTC timezone and ISO format.
284
+ 6. `parentId` &mdash; [`string`, `None`] The ID of the direct parent post or comment.
285
+ 7. `parentPostId` &mdash; [`string`, `None`] The ID of the parent post. For posts, this field will always be `None` since posts have no parent.
286
+ 8. `parentPostUrl` &mdash; [`string`, `None`] The URL of the parent post. For posts, this field will always be `None` since posts have no parent.
287
+ 9. `postType` &mdash; [`string`, `None`] The post type. Can be any of `text`, `poll`, `link`, `image`, `gallery`, or `video`. For comments, this field will always be `None`.
288
+ 10. `isCrosspost` &mdash; [`boolean`] Whether the post is a crosspost.
289
+ 11. `crosspostParentId` &mdash; [`string`, `None`] The ID of the parent of the crosspost (for posts that are not crossposts, will be `None`).
290
+ 12. `crosspostParentUrl` &mdash; [`string`, `None`] The URL of the parent of the crosspost (for posts that are not crossposts, will be `None`).
291
+ 13. `title` &mdash; [`string`, `None`] The post title (will always be `None` for comments).
292
+ 14. `bodyText` &mdash; [`string`, `None`] The main text content of a post or comment.
293
+ 15. `isEdited` &mdash; [`boolean`] Whether the post or comment is edited.
294
+ 16. `author` &mdash; [`string`] The author of the post or comment.
295
+ 17. `authorFlairText` &mdash; [`string`, `None`] The text content of the author flair or a text version of it.
296
+ 18. `authorFlairImageUrl` &mdash; [`string`, `None`] The URL for the image in an author flair.
297
+ 19. `depth` &mdash; [`integer`, `None`] The comment depth (top-level comments have a depth of `0` and posts have a depth of `None`).
298
+ 20. `postFlair` &mdash; [`string`, `None`] The post flair (will be `None` for comments).
299
+ 21. `isNSFW` &mdash; [`boolean`] Whether the post or comment is NSFW.
300
+ 22. `subreddit` &mdash; [`string`, `None`] The subreddit in which the post or comment was submitted.
301
+ 23. `score` &mdash; [`integer`, `None`] The vote score of the post or comment.
302
+ 24. `upvoteRatio` &mdash; [`float`, `None`] The ratio of upvotes to total number of votes of a post (always `None` for comments).
303
+ 25. `numComments` &mdash; [`integer`, `None`] The number of comments in a post (always `None` for comments).
304
+ 26. `numCrossposts` &mdash; [`integer`, `None`] The number of crossposts for a post (always `None` for comments).
305
+ 27. `externalUrl` &mdash; [`string`, `None`] The external URL in a post. For comments, this field will be `None` because external URLs will be included in the `bodyText` anyway.
306
+ 28. `thumbnailUrl` &mdash; [`string`, `None`] The thumbnail image URL for `video`, `image`, and `gallery` post types (always `None` for any other submission).
307
+ 29. `videoUrl` &mdash; [`string`, `None`] The URL for the video in a post (always `None` for any submission other than `video` posts).
308
+ 30. `imageUrl` &mdash; [`string`, `None`] The URL for the image in a post (always `None` for any submission other than `image` posts).
309
+ 31. `galleryImagesUrls` &mdash; [`list`] A list of URLs for all images in a gallery (always empty for any submission other than `gallery` posts).
310
+
311
+ ## Features
312
+
313
+ - 🚀 **Async-First:** High-performance asynchronous scraping with `asyncio` and an async iterator for streaming results.
314
+ - 🔑 **No API Key Required:** Scrape Reddit without requiring an API key.
315
+ - 🔍 **Multiple Search Modes:** Scrape subreddits, user profiles, and specific posts, or search Reddit by keywords and domains.
316
+ - 💬 **Comprehensive Data Extraction:** Collect posts and comments with 30+ structured fields, including authors, scores, timestamps, flairs, media URLs, and comment thread metadata.
317
+ - 🌐 **Flexible HTTP Clients:** Choose between `curl_cffi` for lightweight HTTP requests and `camoufox` for intelligent, browser-based fetching.
318
+ - 🛡️ **Resilient Scraping:** Built-in retries, cookie renewal, and configurable proxies.
319
+ - ⚙️ **Fine-Grained Control:** Configure sorting, time frames, result limits, comment depth, and comment counts.
320
+ - 🧩 **Standalone HTTP Client:** Use Reddrix's asynchronous `get()` method in your own custom scraping workflows.
321
+ - 🐍 **Pythonic API:** Manage scraper resources with an async context manager or explicit `start()` and `stop()` methods.
322
+
323
+ ## Scraper Options
324
+
325
+ 1. `mode` (string) &mdash; One of `standard`, `keyword_search`, and `domain_search`. Default is `standard`.
326
+ 2. `http_client` (string) &mdash; One of `curl_cffi` and `camoufox`. Default is `curl_cffi`.
327
+ 3. `max_results` (integer) &mdash; The maximum total number of items (posts and comments combined) to return across all sources. Default is `999999`.
328
+ 4. `max_posts_per_collection` (integer) &mdash; The maximum number of posts to scrape from each collection. A collection is a single subreddit, profile, keyword search, or domain. Default is `999999`.
329
+ 5. `sort` (string) &mdash; One of `default`, `new`, and `hot`. Applies to subreddits, profiles, and `domain_search`. This option is ignored in `keyword_search` mode, which always uses Reddit's relevance sorting. Default is `default`.
330
+ 6. `time_frame` (string) &mdash; One of `all_time`, `past_hour`, `today`, `past_week`, `past_month`, and `past_year`. Used in `standard` mode for subreddits and profiles, and ignored in `keyword_search` and `domain_search` modes. Default is `all_time`.
331
+ 7. `subreddit_urls` (list of strings) &mdash; Subreddit URLs to scrape, e.g. `["https://www.reddit.com/r/webscraping"]`. Used in `standard` mode only. URLs that are not valid subreddit URLs are skipped. Default is `[]`.
332
+ 8. `post_urls` (list of strings) &mdash; Specific post URLs to scrape, e.g. `["https://www.reddit.com/r/webscraping/comments/abc123/post_title/"]`. Used in `standard` mode only. URLs that are not valid post URLs are skipped. Default is `[]`.
333
+ 9. `profile_urls` (list of strings) &mdash; User profile URLs to scrape the submitted posts of, e.g. `["https://www.reddit.com/user/username"]`. Both `/user/` and `/u/` URLs are supported. Used in `standard` mode only. URLs that are not valid profile URLs are skipped. Default is `[]`.
334
+ 10. `domains` (list of strings) &mdash; Domains to search for in Reddit posts that link to them, e.g. `["github.com", "apify.com"]`. Used in `domain_search` mode only. Default is `[]`.
335
+ 11. `query` (string) &mdash; The search keywords to look up site-wide on Reddit. Used in `keyword_search` mode only. Default is `None`.
336
+ 12. `include_comments` (boolean) &mdash; Whether to scrape the comments of each post in addition to the post itself. Comments are returned as separate items with `submissionType` set to `comment`. Default is `False`.
337
+ 13. `max_comments_depth` (integer) &mdash; The maximum comment depth to scrape. Top-level comments have a depth of `0`, their replies have a depth of `1`, and so on. Only applies if `include_comments` is `True`. Default is `10`.
338
+ 14. `max_comments_per_post` (integer) &mdash; The maximum total number of comments (top-level comments and replies) to scrape per post. Only applies if `include_comments` is `True`. Default is `999999`.
339
+ 15. `max_top_comments_per_post` (integer) &mdash; The maximum number of top-level comments (depth `0`) to scrape per post. Only applies if `include_comments` is `True`. Default is `999999`.
340
+ 16. `proxies` (list of strings) &mdash; A list of proxy URLs in the format `scheme://user:pass@hostname:port`. Reddrix rotates through them automatically, picking an unused proxy first and reusing proxies only after the whole list has been used. Default is `[]` (no proxy).
341
+ 17. `verbose` (boolean) &mdash; Whether to print timestamped log messages (initialization, retries, etc.) to the console. Default is `False`.