Skip to content

Instantly share code, notes, and snippets.

@BruceZhang1993
Created September 5, 2021 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BruceZhang1993/85c3394564526539cb27a3d64bb8ebcd to your computer and use it in GitHub Desktop.
Save BruceZhang1993/85c3394564526539cb27a3d64bb8ebcd to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
#*-- coding:utf8 --
import aiohttp
import asyncio
import json
json_str = ''
async def main():
session = aiohttp.ClientSession()
data = json.loads(json_str)
url = data.get('url')
text = data.get('text', 'emote')
if url is not None:
# 导出表情标签图标
with open(f'{text}.png', 'wb') as f:
async with session.get(url) as response:
f.write(await response.read())
f.flush()
for emote in data.get('emote'):
# 导出表情
emote_url = emote.get('url')
emote_text = emote.get('meta', {}).get('alias')
if emote_text is None:
emote_text.emote.get('text').strip('[]')
with open(f'{emote_text}.png', 'wb') as f:
async with session.get(emote_url) as response:
f.write(await response.read())
f.flush()
await session.close()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment