Home > Backend Development > Python Tutorial > Share an example of implementing dns query function in Python

Share an example of implementing dns query function in Python

零下一度
Release: 2017-05-26 17:43:17
Original
1955 people have browsed it

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)
Copy after login

[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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template