Use Python to send haeder/Then read the returned header information to see what Web server program the website is using.
This morning saw someone using Java to write a program like this, I use Python also a reality, originally wanted to put nginx not version of the count together, think not necessary. Results look at, or nginx more, followed by Apache, then IIS, Tengine This is also more Doha, should be counted as Nginx ha. Of course, there are also many companies with their own writing, such as Baidu's Bws,google GWS. There are also CWS and QWS.
#! /bin/pythonimport socket# counts the number of servers in a dictionary countdict = {"error": 0} #请求内容request = ' ' head/http/1.1accept: */*host:% (SIP ) sconnection:keep-alive ' #print (countdict) print ("{0:*^6}". Format ("HOST"), "{0:*^26}". Format ("WEB SITE"), "{0:*^6 } ". Format (" server: ")," {0:*^26} ". Format (" Server Name ")) Print ("-------------------------------------------------- ---------------") fp = open (' Serverlist.txt ', ' R ') for ServerIP in Fp:serverip = Serverip.strip () #print (Request% di CT (sip = serverip)) #针对不同网站替换点请求的Host字段 TT = Request% dict (sip = ServerIP) #print (TT) #请求header try: s = socket.socket (socket.af_inet, socket. Sock_stream) S.connect ((ServerIP,)) S.send (Tt.encode ()) recv = S.recv (1024x768) recv = RECV.D Ecode () #print (Recv.decode ()) except Timeouterror as Te:print ("HOST:", ServerIP, "Report Connection timeout error") countdict["Error"] =+ 1 print ("-----------------------------------------------------------------") continue Except Exception as E:print ("HOST:", ServerIP, "reported unknown error") countdict["error"] =+ 1 print ("---- -------------------------------------------------------------") Continue #print (recv) recvlist = Recv.split (' \ r \ n ') for a in recvlist: #if ' server: ' In A and A.startswith (' Server: '): If A.startswith (' Server: '): ServerName = A.split (': ') [1] #统计应用的服务器名了 if servername in Countdict:countdict[servername] + = 1 El Se:countdict[servername] = 1 #格式化打印 #print ("HOST:", ServerIP, "Server:", servername) print ("{0: <6}" . Format ("HOST:"), "{0: <26}". Format (ServerIP), "{0: <6}". Format ("Server:"), "{0: <26}". Format (ServerName)) p Rint ("-----------------------------------------------------------------") #打印统计结果print (countdict)
This is when there are only a few websites in Serverlist.txt.
This is after adding a lot of websites.
Python3 use the socket to see the Web server programs used by the major websites to see which one is used the most.