My college has some ports. Something like this http://www.college.in:913 I want a program to find the active ones. I mean I want those port number in which the website is working. Here is a code. But it takes a lot of time. from urllib.request import Request, urlopen from urllib.error import URLError, HTTPError for i in range(1,10000): req = Request("http://college.edu.in:"+str(i)) try: response = urlopen(req) except URLError as e: print("Error at port"+str(i) ) else: print ('Website is working fine'+str(i)) Continue reading...