use Python to fragment whois information into a database
Whois server returns the WHOIS dictionary information will be very long, some domain name whois information has 2000+ byte, will return the WHOIS information to slice processing, the procedure chooses divides it into 9 pieces, in the database
Keyword matching can also be stored, but the information will not be comprehensive, the two methods have advantages and disadvantages.
Here is the Python source code for the fragment processing
"'--------------------------ver:2.0 date:2017/11/22 auth:wud--------------------- -----' Import DNS import mysqldb import whois import sys from time import CTime to import time D EF Getwhois (URL): try:print "Finding whois information ..." data = Whois.whois (URL) print "Who
is Query successfully! "
#print Data return Data except:print "whois query fail!" Pass def getip (URL): try:query = sys.argv[0] DNS. Discovernameservers () Reqobj = DNS. Request (URL) answerobj = Reqobj.req (Name=query, Qtype=dns. TYPE.A) if not Len (answerobj.answers): Return to item in ANSWEROBJ.ANSWERS:IP = ("%s")% (item[' data ']) print "IP is:", IP return IP except:print "Time Out" F2 = Op En ("fail.txt", ' r+ ') print >> f2, url f2.close () Pass DEF WHOisoperation (ip,url,data): info = str (data) size = Len (info) info1 = info[:size/9] Info2 = Info[size/9:siz E*2/9] Info3 = info[size*2/9:size*3/9] Info4 = Info[size*3/9:size*4/9] Info5 = INFO[SIZE*4/9:SIZE*5/9] inf O6 = INFO[SIZE*5/9:SIZE*6/9] Info7 = INFO[SIZE*6/9:SIZE*7/9] Info8 = INFO[SIZE*7/9:SIZE*8/9] Info9 = info[size *8/9:] #print "^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ The ^^ the ^^ the ^^ ^^ the ^^ the ^^ the ^^ the ^^ the ^^ the ^^ ^^ the ^^ the ^^, the ^^ the ^^ the ^^ ^^ a ^^ of the Info2 3, "\ n", Info4, "\ n", Info5, "\ n", Info6, "\ n", Info7, "\ n", Info8, "\ n", Info9 #print "^^ ^^ ^^ ^^ ^^ ^^ ^^ The ^^ of a ^^ to the ^^ the ^^ of the ^^, ^^ ^^ the ^^ ^^ the ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ "^^ = Info[len/9:len/9] try:print" Databaes connecting "db = M
Ysqldb.connect ("***.***.***.***", "* * *", "********", "* * *", charset= "UTF8") print "connected!" cursor = Db.cursor () cursor.execute (' INSERT into Whois_info2 (url,ip,info_1,info_2,info_3,info_4,info_5,info_6,inf O_7,info_8,info_9,insert_time) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ', [Url,ip,info1,info2,info3,info4,info5,info6,info7,info8,info9,ctime ()])
Db.commit () print "Insert successfully!" Except:print "Error" def main (): F = open ("Whois_test.txt", ' r ') f1 = open ("Whois.txt", ' r+ ') flag =
"A" (flag>0): a = time.time () url = f.readline () [: -2] print 93-flag print URL
ip = getip (URL) data = Getwhois (URL) whoisoperation (ip,url,data) print >>f1, url
Print >>f1, IP print >>f1, data print "Using time:", Time.time ()-A sleep (10)
flag-=1 if __name__ = = ' __main__ ': Main ()