import urllib2- def scanhttp(url):
- try:
- response = urllib2.urlopen(url, timeout=1)
- try:
- html = response.read()
- print "%s is 200" %url
- except Exception, e:
- print "response 200 ,but it is no a web service "
- print e
- except urllib2.HTTPError, e:
- print url,
- print "HTTPError:%s" %e
- except urllib2.URLError, e:
- print url,
- print 'the url is wrong or It is no a web service'
- except :
- print url,
- print 'other error '
- if __name__ == '__main__':
- urllist = ['http://192.168.0.1:9001',
- 'http://192.168.0.1:3032',
- 'http://127.0.0.1:8087',
- 'http://192.168.0.1:5355',
- 'http://127.0.0.1:5900',
- 'http://127.0.0.1:8384',
- 'http://127.0.0.1:8086',
- ]
- for url in urllist:
- scanhttp(url)