ugcscraper-helper 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 UGC Scraper
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.
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: ugcscraper-helper
3
+ Version: 0.1.0
4
+ Summary: A tiny Python client for the UGC Scraper Reddit API — scrape posts and comments into clean JSON without Reddit API keys or proxies.
5
+ License: MIT
6
+ Project-URL: Homepage, https://ugcscraper.com
7
+ Project-URL: Documentation, https://ugcscraper.com/reddit-scraper-api
8
+ Project-URL: Repository, https://github.com/builtbyish/ugc-scraper-python-helper
9
+ Keywords: reddit,reddit-scraper,reddit-comment-scraper,web-scraping,praw-alternative
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: requests>=2.25
14
+ Dynamic: license-file
15
+
16
+ # ugc-scraper-python-helper
17
+
18
+ A lightweight **Reddit scraper Python** client for the [UGC Scraper](https://ugcscraper.com) API.
19
+ Scrape any Reddit post and its full comment thread into clean, consistent JSON, with **no Reddit API
20
+ keys**, no OAuth app, and no proxies to manage.
21
+
22
+ It is a ~90-line wrapper over the [UGC Scraper Platform](https://ugcscraper.com) REST API. One key,
23
+ one endpoint, the same JSON schema every time, so you can build your parser once.
24
+
25
+ ## Why
26
+
27
+ Most ways to scrape Reddit break on the same things: the official API needs OAuth and caps listings
28
+ at ~1,000 items, and DIY scrapers get IP-banned without a rotating proxy pool. UGC Scraper routes
29
+ every request through a resilient fallback chain with automatic failover and bills only for
30
+ successful posts. This helper is the smallest possible way to call it from Python.
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ pip install requests # the only dependency
36
+ # then drop ugcscraper.py into your project, or:
37
+ pip install .
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ```python
43
+ from ugcscraper import UGCScraper
44
+
45
+ client = UGCScraper("rps_live_your_key") # get a free key at ugcscraper.com/dashboard
46
+
47
+ # Scrape a post + its full comment thread into one JSON schema
48
+ post = client.scrape("https://www.reddit.com/r/python/comments/abc123/")
49
+ print(post["title"], post["score"], len(post["comments"]))
50
+
51
+ # Read your durable scrape history (free, no quota)
52
+ print(client.history(limit=20))
53
+ print(client.latest("abc123")) # re-fetch a stored post without spending quota
54
+ print(client.usage()) # tier, quota, remaining
55
+
56
+ # Export the same data as CSV
57
+ open("comments.csv", "w").write(client.latest_csv("abc123", rows="comments"))
58
+ open("history.csv", "w").write(client.history_csv())
59
+ ```
60
+
61
+ Errors surface as `UGCScraperError` with the API's `status_code` and `detail` (401 invalid key,
62
+ 429 rate limit, 502 all methods failed).
63
+
64
+ ## What you get back
65
+
66
+ A flattened, LLM-friendly schema: `title`, `author`, `score`, `num_comments`, `permalink`,
67
+ `image_url`, `thumbnail_url`, `body`, and `comments[]` (each with `author`, `body`, `score`, `id`,
68
+ `parent_id`, `link_id`, `permalink`, `created_at`). Same shape no matter which engine fetched it.
69
+
70
+ ## Links
71
+
72
+ - Platform: <https://ugcscraper.com>
73
+ - API reference (endpoints, auth, examples): <https://ugcscraper.com/reddit-scraper-api>
74
+ - Get an API key (free tier: 1,000 successful posts/mo): <https://ugcscraper.com/dashboard>
75
+ - MCP server for Claude Desktop: `ugc-scraper-reddit-mcp`
76
+
77
+ ## License
78
+
79
+ MIT
@@ -0,0 +1,64 @@
1
+ # ugc-scraper-python-helper
2
+
3
+ A lightweight **Reddit scraper Python** client for the [UGC Scraper](https://ugcscraper.com) API.
4
+ Scrape any Reddit post and its full comment thread into clean, consistent JSON, with **no Reddit API
5
+ keys**, no OAuth app, and no proxies to manage.
6
+
7
+ It is a ~90-line wrapper over the [UGC Scraper Platform](https://ugcscraper.com) REST API. One key,
8
+ one endpoint, the same JSON schema every time, so you can build your parser once.
9
+
10
+ ## Why
11
+
12
+ Most ways to scrape Reddit break on the same things: the official API needs OAuth and caps listings
13
+ at ~1,000 items, and DIY scrapers get IP-banned without a rotating proxy pool. UGC Scraper routes
14
+ every request through a resilient fallback chain with automatic failover and bills only for
15
+ successful posts. This helper is the smallest possible way to call it from Python.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pip install requests # the only dependency
21
+ # then drop ugcscraper.py into your project, or:
22
+ pip install .
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```python
28
+ from ugcscraper import UGCScraper
29
+
30
+ client = UGCScraper("rps_live_your_key") # get a free key at ugcscraper.com/dashboard
31
+
32
+ # Scrape a post + its full comment thread into one JSON schema
33
+ post = client.scrape("https://www.reddit.com/r/python/comments/abc123/")
34
+ print(post["title"], post["score"], len(post["comments"]))
35
+
36
+ # Read your durable scrape history (free, no quota)
37
+ print(client.history(limit=20))
38
+ print(client.latest("abc123")) # re-fetch a stored post without spending quota
39
+ print(client.usage()) # tier, quota, remaining
40
+
41
+ # Export the same data as CSV
42
+ open("comments.csv", "w").write(client.latest_csv("abc123", rows="comments"))
43
+ open("history.csv", "w").write(client.history_csv())
44
+ ```
45
+
46
+ Errors surface as `UGCScraperError` with the API's `status_code` and `detail` (401 invalid key,
47
+ 429 rate limit, 502 all methods failed).
48
+
49
+ ## What you get back
50
+
51
+ A flattened, LLM-friendly schema: `title`, `author`, `score`, `num_comments`, `permalink`,
52
+ `image_url`, `thumbnail_url`, `body`, and `comments[]` (each with `author`, `body`, `score`, `id`,
53
+ `parent_id`, `link_id`, `permalink`, `created_at`). Same shape no matter which engine fetched it.
54
+
55
+ ## Links
56
+
57
+ - Platform: <https://ugcscraper.com>
58
+ - API reference (endpoints, auth, examples): <https://ugcscraper.com/reddit-scraper-api>
59
+ - Get an API key (free tier: 1,000 successful posts/mo): <https://ugcscraper.com/dashboard>
60
+ - MCP server for Claude Desktop: `ugc-scraper-reddit-mcp`
61
+
62
+ ## License
63
+
64
+ MIT
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ugcscraper-helper"
7
+ version = "0.1.0"
8
+ description = "A tiny Python client for the UGC Scraper Reddit API — scrape posts and comments into clean JSON without Reddit API keys or proxies."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ keywords = ["reddit", "reddit-scraper", "reddit-comment-scraper", "web-scraping", "praw-alternative"]
13
+ dependencies = ["requests>=2.25"]
14
+
15
+ [project.urls]
16
+ Homepage = "https://ugcscraper.com"
17
+ Documentation = "https://ugcscraper.com/reddit-scraper-api"
18
+ Repository = "https://github.com/builtbyish/ugc-scraper-python-helper"
19
+
20
+ [tool.setuptools]
21
+ py-modules = ["ugcscraper"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,91 @@
1
+ """A tiny Python client for the UGC Scraper Reddit API (https://ugcscraper.com).
2
+
3
+ Scrape a Reddit post and its full comment thread into clean, consistent JSON with no Reddit API
4
+ keys and no proxies. Depends only on `requests`.
5
+
6
+ from ugcscraper import UGCScraper
7
+
8
+ client = UGCScraper("rps_live_your_key")
9
+ post = client.scrape("https://www.reddit.com/r/python/comments/abc123/")
10
+ print(post["title"], len(post["comments"]))
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from typing import Any
16
+
17
+ import requests
18
+
19
+ __all__ = ["UGCScraper", "UGCScraperError"]
20
+ __version__ = "0.1.0"
21
+
22
+ DEFAULT_BASE_URL = "https://api.ugcscraper.com"
23
+
24
+
25
+ class UGCScraperError(RuntimeError):
26
+ """Raised when the API returns a non-2xx response (401 auth, 429 rate limit, 502, ...)."""
27
+
28
+ def __init__(self, status_code: int, detail: str):
29
+ self.status_code = status_code
30
+ self.detail = detail
31
+ super().__init__(f"UGC Scraper API error {status_code}: {detail}")
32
+
33
+
34
+ class UGCScraper:
35
+ """Thin wrapper over the UGC Scraper REST API. One key, one endpoint, clean JSON back."""
36
+
37
+ def __init__(self, api_key: str, base_url: str = DEFAULT_BASE_URL, timeout: int = 60):
38
+ if not api_key:
39
+ raise ValueError("api_key is required (get one at https://ugcscraper.com/dashboard)")
40
+ self.base_url = base_url.rstrip("/")
41
+ self.timeout = timeout
42
+ self._session = requests.Session()
43
+ self._session.headers.update({"Authorization": f"Bearer {api_key}"})
44
+
45
+ # -- core ----------------------------------------------------------------
46
+ def scrape(self, url: str) -> dict[str, Any]:
47
+ """Scrape a Reddit post URL (or bare post id) into one consistent JSON schema.
48
+
49
+ Counts against your monthly quota only on success. Raises UGCScraperError on failure.
50
+ """
51
+ return self._request("POST", "/v1/scrape", json={"url": url}).json()
52
+
53
+ # -- durable history -----------------------------------------------------
54
+ def history(self, post_id: str | None = None, limit: int = 50) -> dict[str, Any]:
55
+ """List durable snapshots you have already scraped (summaries). Reading history is free."""
56
+ params: dict[str, Any] = {"limit": limit}
57
+ if post_id:
58
+ params["post_id"] = post_id
59
+ return self._request("GET", "/v1/history", params=params).json()
60
+
61
+ def latest(self, post_id: str) -> dict[str, Any]:
62
+ """Re-fetch the most recent stored full post for a post id, without spending quota."""
63
+ return self._request("GET", f"/v1/history/{post_id}/latest").json()
64
+
65
+ def usage(self) -> dict[str, Any]:
66
+ """Your plan tier, monthly quota, usage, and remaining successful-post allowance."""
67
+ return self._request("GET", "/v1/usage").json()
68
+
69
+ # -- CSV export ----------------------------------------------------------
70
+ def history_csv(self, post_id: str | None = None, limit: int = 50) -> str:
71
+ """The same history as CSV text (one row per snapshot)."""
72
+ params: dict[str, Any] = {"limit": limit, "format": "csv"}
73
+ if post_id:
74
+ params["post_id"] = post_id
75
+ return self._request("GET", "/v1/history", params=params).text
76
+
77
+ def latest_csv(self, post_id: str, rows: str = "comments") -> str:
78
+ """A stored post as CSV text: rows='comments' (one row per comment) or rows='post'."""
79
+ params = {"format": "csv", "rows": rows}
80
+ return self._request("GET", f"/v1/history/{post_id}/latest", params=params).text
81
+
82
+ # -- internal ------------------------------------------------------------
83
+ def _request(self, method: str, path: str, **kwargs: Any) -> requests.Response:
84
+ resp = self._session.request(method, self.base_url + path, timeout=self.timeout, **kwargs)
85
+ if not resp.ok:
86
+ try:
87
+ detail = resp.json().get("detail", resp.text)
88
+ except ValueError:
89
+ detail = resp.text
90
+ raise UGCScraperError(resp.status_code, str(detail))
91
+ return resp
@@ -0,0 +1,79 @@
1
+ Metadata-Version: 2.4
2
+ Name: ugcscraper-helper
3
+ Version: 0.1.0
4
+ Summary: A tiny Python client for the UGC Scraper Reddit API — scrape posts and comments into clean JSON without Reddit API keys or proxies.
5
+ License: MIT
6
+ Project-URL: Homepage, https://ugcscraper.com
7
+ Project-URL: Documentation, https://ugcscraper.com/reddit-scraper-api
8
+ Project-URL: Repository, https://github.com/builtbyish/ugc-scraper-python-helper
9
+ Keywords: reddit,reddit-scraper,reddit-comment-scraper,web-scraping,praw-alternative
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: requests>=2.25
14
+ Dynamic: license-file
15
+
16
+ # ugc-scraper-python-helper
17
+
18
+ A lightweight **Reddit scraper Python** client for the [UGC Scraper](https://ugcscraper.com) API.
19
+ Scrape any Reddit post and its full comment thread into clean, consistent JSON, with **no Reddit API
20
+ keys**, no OAuth app, and no proxies to manage.
21
+
22
+ It is a ~90-line wrapper over the [UGC Scraper Platform](https://ugcscraper.com) REST API. One key,
23
+ one endpoint, the same JSON schema every time, so you can build your parser once.
24
+
25
+ ## Why
26
+
27
+ Most ways to scrape Reddit break on the same things: the official API needs OAuth and caps listings
28
+ at ~1,000 items, and DIY scrapers get IP-banned without a rotating proxy pool. UGC Scraper routes
29
+ every request through a resilient fallback chain with automatic failover and bills only for
30
+ successful posts. This helper is the smallest possible way to call it from Python.
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ pip install requests # the only dependency
36
+ # then drop ugcscraper.py into your project, or:
37
+ pip install .
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ```python
43
+ from ugcscraper import UGCScraper
44
+
45
+ client = UGCScraper("rps_live_your_key") # get a free key at ugcscraper.com/dashboard
46
+
47
+ # Scrape a post + its full comment thread into one JSON schema
48
+ post = client.scrape("https://www.reddit.com/r/python/comments/abc123/")
49
+ print(post["title"], post["score"], len(post["comments"]))
50
+
51
+ # Read your durable scrape history (free, no quota)
52
+ print(client.history(limit=20))
53
+ print(client.latest("abc123")) # re-fetch a stored post without spending quota
54
+ print(client.usage()) # tier, quota, remaining
55
+
56
+ # Export the same data as CSV
57
+ open("comments.csv", "w").write(client.latest_csv("abc123", rows="comments"))
58
+ open("history.csv", "w").write(client.history_csv())
59
+ ```
60
+
61
+ Errors surface as `UGCScraperError` with the API's `status_code` and `detail` (401 invalid key,
62
+ 429 rate limit, 502 all methods failed).
63
+
64
+ ## What you get back
65
+
66
+ A flattened, LLM-friendly schema: `title`, `author`, `score`, `num_comments`, `permalink`,
67
+ `image_url`, `thumbnail_url`, `body`, and `comments[]` (each with `author`, `body`, `score`, `id`,
68
+ `parent_id`, `link_id`, `permalink`, `created_at`). Same shape no matter which engine fetched it.
69
+
70
+ ## Links
71
+
72
+ - Platform: <https://ugcscraper.com>
73
+ - API reference (endpoints, auth, examples): <https://ugcscraper.com/reddit-scraper-api>
74
+ - Get an API key (free tier: 1,000 successful posts/mo): <https://ugcscraper.com/dashboard>
75
+ - MCP server for Claude Desktop: `ugc-scraper-reddit-mcp`
76
+
77
+ ## License
78
+
79
+ MIT
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ ugcscraper.py
5
+ ugcscraper_helper.egg-info/PKG-INFO
6
+ ugcscraper_helper.egg-info/SOURCES.txt
7
+ ugcscraper_helper.egg-info/dependency_links.txt
8
+ ugcscraper_helper.egg-info/requires.txt
9
+ ugcscraper_helper.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.25