多线程:获取网页状态码

#-*- 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'又完事儿了。。'

posted @ 2014-12-17 09:28  _No.47  阅读(203)  评论(0编辑  收藏  举报