多线程:获取网页状态码

时间:2014-12-17 09:42:56   收藏:0   阅读:192
#-*- coding:utf-8 -*-  
import urllib
import threading

def func(url):
    status = urllib.urlopen(url).code
    print status
    
urlinfo = [http://www.sohu.com,http://www.163.com,http://www.sina.com]
for url in urlinfo:
    th = threading.Thread(target = func,args = [url])
    th.start()
    th.join()
    
print u又完事儿了。。

bubuko.com,布布扣

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!