-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrun_python_api.py
More file actions
36 lines (26 loc) · 870 Bytes
/
Copy pathrun_python_api.py
File metadata and controls
36 lines (26 loc) · 870 Bytes
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
from __future__ import annotations
from pathlib import Path
from scrapi_reddit import ScrapeOptions, build_search_target, build_session, process_listing
def main() -> None:
"""Demonstrate the Python API by running a small search scrape."""
session = build_session("scrapi-reddit-example/0.1", verify=True)
options = ScrapeOptions(
output_root=Path("./example_runs"),
listing_limit=25,
comment_limit=100,
delay=1.5,
time_filter="day",
output_formats={"json", "csv"},
fetch_comments=True,
resume=True,
download_media=False,
)
target = build_search_target(
"python asyncio",
search_types=["comment"],
sort="new",
time_filter="week",
)
process_listing(target, session=session, options=options)
if __name__ == "__main__":
main()