Skip to content

Instantly share code, notes, and snippets.

@fhefh2015
Forked from yingca1/dl.py
Created October 24, 2016 11:52
Show Gist options
  • Save fhefh2015/acbcfc4ab1c87f5336eab5a2097465af to your computer and use it in GitHub Desktop.
Save fhefh2015/acbcfc4ab1c87f5336eab5a2097465af to your computer and use it in GitHub Desktop.
import urllib.request
import asyncio
import json
r = urllib.request.urlopen('https://raw.githubusercontent.com/spacelan/wechat-emoticon/master/emoticons.json').read().decode('utf8')
json_obj = json.loads(r)
@asyncio.coroutine
def download(todo):
urllib.request.urlretrieve(todo.get('url'), todo.get('md5') + '.gif')
loop = asyncio.get_event_loop()
tasks = [download(todo) for todo in json_obj]
loop.run_until_complete(asyncio.wait(tasks))
loop.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment