Update sync

- Add export & import build example
This commit is contained in:
M307 (Mac) 2023-02-17 01:38:37 +07:00
parent 8a7684ac9e
commit 80442f1ec4
5 changed files with 28 additions and 2 deletions

3
.gitignore vendored
View File

@ -1,6 +1,6 @@
__pycache__
enkanetwork.egg-info
build
./build
enkanetwork.py.egg-info
dist
test/*.test.py
@ -9,3 +9,4 @@ test/*.test.py
git-story_media
env
export.json
843715177.json

View File

@ -0,0 +1,16 @@
import asyncio
import json
from enkanetwork import EnkaNetworkAPI
client = EnkaNetworkAPI(lang="th")
async def main():
async with client:
# Fetch data
raw = await client.fetch_raw_data(843715177)
# Write JSON file
with open(f"./{raw['uid']}.json", "w", encoding="utf-8") as w:
json.dump(raw, w, indent=4)
asyncio.run(main())

View File

@ -0,0 +1,9 @@
import json
from enkanetwork.model.base import EnkaNetworkResponse
UID = "843715177"
with open(f"./{UID}.json" , "r", encoding="utf-8") as f:
response = EnkaNetworkResponse.parse_obj(json.load(f))
print(response)