nslookup的python模块 [英] python module for nslookup

查看:799
本文介绍了nslookup的python模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个python模块与nslookup的功能相同? 我计划使用nslookup来挖掘有关要废弃的URL的域的一些信息.我知道我可以使用os.sys来调用nslookup,但是我只是想知道是否已经有一个python模块了. 预先感谢!

Is there a python-module that's doing the same stuff as nslookup does? I am planning to use nslookup on digging some information regarding the domain of a URL to be scrapped. I know I can use os.sys to call nslookup but I am just wondering if there is a python-module for this already. Thanks in advance!

推荐答案

我正在使用以下代码:

import socket

ip_list = []
ais = socket.getaddrinfo("www.yahoo.com",0,0,0,0)
for result in ais:
  ip_list.append(result[-1][0])
ip_list = list(set(ip_list))

或者将理解理解为:

ip_list = list({addr[-1][0] for addr in socket.getaddrinfo(name, 0, 0, 0, 0)})

这篇关于nslookup的python模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆