mirror of
https://github.com/PaiGramTeam/EnkaNetwork.py.git
synced 2024-11-16 03:45:28 +00:00
Update sync
- Add export & import build example
This commit is contained in:
parent
8a7684ac9e
commit
80442f1ec4
3
.gitignore
vendored
3
.gitignore
vendored
@ -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
|
16
example/build/export_build.py
Normal file
16
example/build/export_build.py
Normal 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())
|
9
example/build/import_build.py
Normal file
9
example/build/import_build.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user