相关疑难解决方法(0)

如何在Python中解析DNS?

我有一个DNS脚本,允许用户通过在Windows命令提示符下键入网站名称来解析DNS名称.

我查看了有关DNS解析的几个指南,但我的脚本似乎无法将名称(www.google.com)或(google.com)解析为IP地址.

该脚本输出错误

Traceback (most recent call last):
  File "C:\python\main_menu.py", line 37, in ?
    execfile('C:\python\showdns.py')
  File "C:\python\showdns.py", line 3, in ?
    x = input ("\nPlease enter a domain name that you wish to translate: ")
  File "<string>", line 0, in ?
NameError: name 'google' is not defined
Run Code Online (Sandbox Code Playgroud)

代码:

import socket

x = input ("\nPlease enter a domain name that you wish to translate: ")

print ("\n\nThe IP Address of the Domain Name is: "+socket.gethostbyname_ex(x))

x = raw_input("\nSelect enter to proceed …
Run Code Online (Sandbox Code Playgroud)

python reverse-dns

14
推荐指数
2
解决办法
4万
查看次数

标签 统计

python ×1

reverse-dns ×1