Skip to content

Commit 8906f6a

Browse files
committed
feat: enhance get_json function to handle None page argument by fetching JSON directly
1 parent e79233c commit 8906f6a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

esd/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ def get_json(page: Page, url: str) -> dict:
6363
"""
6464

6565
try:
66+
if page is None:
67+
with httpx.Client() as client:
68+
response = client.get(url)
69+
response.raise_for_status()
70+
return response.json()
6671
page.goto(url, wait_until="networkidle")
6772
content = page.content()
6873
doc = html.fromstring(content)

0 commit comments

Comments
 (0)