我有一个 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
编码:
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 back to Main Menu\n")
if x == '1':
execfile('C:\python\main_menu.py')
请提供有关代码的建议。谢谢!