This article mainly introduces the simple dns query function implemented in Python, and analyzes the dns information query implementation skills of Python based on the socket module in the form of examples. Friends in need can refer to it
The examples in this article describe Python Implemented simple dns query function. Share it with everyone for your reference, the details are as follows:
#!/usr/bin/python import sys,socket def print_array(*arr): array = arr for item in array: print item[4][0] print '''this script is for host resolve print "now this begin... if you want to leave,please input "break"''' while 1: try: host = raw_input("please input the host: ") except KeyboardInterrupt: print "\n", continue except : print "\n", continue if host == "break" or host == "": break result = socket.getaddrinfo(host,None,0,socket.SOCK_STREAM) print_array(*result)
[Related recommendations]
1. 2. Use Python to implement the Youku video batch download function example
3. Share an example tutorial of and / or operation logic in python
4. Python: Logical judgment and operator examples
The above is the detailed content of Share an example of implementing dns query function in Python. For more information, please follow other related articles on the PHP Chinese website!