import urllib.request import gevent from gevent import monkey# 打补丁monkey.patch_all() def downloader(img_name, img_url): req = urllib.request.urlopen(img_url) img_content = req.read() with open(img_name, " wb " ) as f: f.write(img_cont
import urllib.request import gevent from gevent import monkey # 打补丁 monkey.patch_all() def downloader(img_name, img_url): req = urllib.request.urlopen(img_url) img_content = req.read() with open(img_name, "wb") as f: f.write(img_content) def main(): gevent.joinall([ gevent.spawn(downloader, "h2.html", "https://hnfile.artlets.cnhttp://img.558idc.com/uploadfile/tkTicket/12/0214003019238-dcd1bd93.html"), ]) if __name__ == ‘__main__‘: main()