我想測試整個網站列表以查看網址是否有效,並且我想知道哪些網址沒有。使用Python檢查網址
import urllib2
filename=open(argfile,'r')
f=filename.readlines()
filename.close()
def urlcheck() :
for line in f:
try:
urllib2.urlopen()
print "SITE IS FUNCTIONAL"
except urllib2.HTTPError, e:
print(e.code)
except urllib2.URLError, e:
print(e.args)
urlcheck()
你的代碼如何不起作用? – usr2564301