协程+IO切换+小爬虫
from gevent import monkey
monkey.patch_all()
import gevent
import requests
def f1(url):
print(f'GET:{url}')
msg = requests.get(url)
# 获取的是网站的数据长度
print(len(msg.content))
gevent.joinall([
gevent.spawn(f1, 'https://www.python.org'),
gevent.spawn(f1, 'https://www.github.com'),
gevent.spawn(f1, 'https://www.yahoo.com')
])