[feat] add fetch function
This commit is contained in:
parent
aec555d1b5
commit
51b61d2db7
1 changed files with 22 additions and 0 deletions
22
demo/activitypub.py
Normal file
22
demo/activitypub.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""ActivityPub settings, fetch & post"""
|
||||||
|
import httpx
|
||||||
|
import config
|
||||||
|
|
||||||
|
|
||||||
|
def fetch(
|
||||||
|
url: str,
|
||||||
|
) -> dict:
|
||||||
|
"""Fetch url and return json"""
|
||||||
|
print(f"fetch {url}")
|
||||||
|
|
||||||
|
with httpx.Client() as client:
|
||||||
|
resp = client.get(
|
||||||
|
url,
|
||||||
|
headers={
|
||||||
|
"User-Agent": config.USER_AGENT,
|
||||||
|
"Accept": config.AP_CONTENT_TYPE,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return resp.json()
|
Loading…
Reference in a new issue