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/'),
#
# ])

相关文章:

  • 2022-01-07
  • 2021-12-08
  • 2021-12-13
  • 2022-02-24
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-08-30
  • 2022-12-23
  • 2021-08-07
  • 2021-11-17
  • 2021-12-10
  • 2021-10-28
  • 2021-09-30
相关资源
相似解决方案