python 功能很强大, 也是一门很容易学习的语言,这里介绍下用python 获取机器代码
直接贴代码来
#获取服务器信息
import urllib2
import socket
import platform
def getServerInfo(serverURL):
'''根据域名获得服务器信息 (网络)
测试:getServerInfo("http://163.com")
'''
try:
sock = urllib2.urlopen(serverURL)
info = sock.headers.values() #可以知道远程服务器操作系统 ,网络等信息
print info
except Exception,err:
print u"域名 不存在"
return
def getLocalHostInfo():
'''获得本地机器信息
'''
print u"操作系统名称及版本号: ",platform.platform()
print u"操作系统的位数: ",platform.architecture()
print u"计算机类型: ", platform.machine()
print u"计算机的网络名称: ", platform.node()
print u"计算机处理器信息: ", platform.processor()