爬虫

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,"3.png","https://rpic.douyucdn.cn/asrpic/190702/96291

_2126.png"),


爬虫_第1张图片

image

gevent.spawn(downloader,"2.png","https://rpic.douyucdn.cn/asrpic/190702/5551871_2128.png"),


爬虫_第2张图片

image

])

ifname== 'main':

main()

你可能感兴趣的:(爬虫)