**** 大家好
我正在使用 eventlet 来实现网络爬虫。我的代码就是这样
import eventlet
urls = [
"http://deeplearning.stanford.edu/wiki/index.php/UFLDL%E6%95%99%E7%A8%8B",
"http://www.google.com.hk",
"http://www.baidu.com",
]
def fetch(url):
print('entering fetch')
body=urllib2.urlopen(url).read()
print('body')
pool = eventlet.GreenPool(100)
for url in urls:
pool.spawn(fetch,url)
time.sleep(10)
但它什么也没输出,似乎 fetch 根本没有运行
顺便说一句,pool.imap 确实有效
发生了什么?
我想要做的是:url 源源不断地来,即一个接一个。像这样
While(True):
url=getOneUrl() #get one url streamly
pool.spawn(fetch,url) #fetch the url
但它也不起作用。
提前致谢....