import urllib.request
import gevent
import gevent.monkey
gevent.monkey.patch_all()
def downloader(img_name, img_url):
req = urllib.request.urlopen(url=img_url)
img_content = req.read()
with open(img_name, 'wb') as f:
f.write(img_content)
def main():
gevent.joinall([gevent.spawn(downloader, '1.jpg', 'https://rpic.douyucdn.cn/live-cover/roomCover/2019/09/05/6668ef0693e932a3fec8994d8bfdcbaf_big.jpg'),
gevent.spawn(downloader, '2.jpg', 'https://rpic.douyucdn.cn/live-cover/appCovers/2019/10/19/7605123_20191019184322_small.jpg')
])
if __name__ == '__main__':
main()