import gevent
from urllib.request import urlopen
# 爬虫
def f(url):
print('GET: %s' % url)
resp = urlopen(url)
data = resp.read()
with open('baidu.html', 'wb') as f:
f.write(data)
print('%d bytes %s' % (len(data), url))
# f('http://www.xiaohuar.com/')
f('http://www.baidu.com/')
# gevent.joinall([
#
# gevent.spawn(f, 'https://www.python.org/'),
# gevent.spawn(f, 'https://www.yahoo.com/'),
#
# ])