Created
October 18, 2016 06:49
-
-
Save yingca1/5ba9c2cd2854814a97f74e402b1f8eaa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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