-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbasic_test.py
More file actions
64 lines (53 loc) · 1.69 KB
/
Copy pathbasic_test.py
File metadata and controls
64 lines (53 loc) · 1.69 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
from BAScraper.service_types import ArcticShiftModel
from BAScraper.service_types import PullPushModel
from BAScraper import BAScraper
from BAScraper.utils import BAConfig
import datetime
import pendulum
import asyncio
import json
def main():
# !! config(validation run) needs to be run before model validation if you want logs
# !! because logging config is done within BAConfig model validation (init.)
conf = BAConfig(
# log_level=logging.DEBUG,
log_file_path="bascraper.log",
log_file_mode="w",
)
example1 = ArcticShiftModel(
no_workers=3,
no_sub_comment_workers=10,
interval_sleep_ms=250,
endpoint="posts",
lookup="search",
# ids=["123123","23we"],
subreddit="r/umamusume",
after="2025-10-25",
before="2025-10-25T12:00:00Z",
# sort="asc",
# limit=50,
# title="release",
fields=["title", "link_flair_text"],
fetch_post_comments=True
)
print(example1.model_dump_json(indent=4, exclude_none=True))
print(f"\n{30*"="}\n")
example2 = PullPushModel(
endpoint="comment",
q='"test phrase"',
ids=['abc123', 'def456'],
size=50,
sort='desc',
# score='>=10',
# title="eee",
# over_18=True,
after=datetime.datetime(2025, 1, 1), # "2023-01-01",
before=pendulum.datetime(2026, 10, 2), #"2026-10-26T15:30:00Z",
)
print(example2.model_dump_json(indent=4, exclude_none=True))
bas = BAScraper(conf)
res = asyncio.run(bas.get(example1))
with open("test.json", "w+") as f:
json.dump(res, f, indent=4)
if __name__ == "__main__":
main()