Python:抓取任意URI的A记录?
我基本上想实现一些可以输入任何 URI 的东西(我可能只会处理 http ),并且我想返回 URI 中域的 A 记录,我想要服务器的 IP 地址。
我知道大多数人使用 ping 命令来查找 IP 地址,但我也知道有更具体的“host”和“dig”。
我可以使用任何本机函数来为我执行此操作吗?如果是这样,该函数在它接受的 URI 字符串及其结构方面有多宽松?我想抛出它:
- http://foo.com
- www.foo.com
- http://foo.com/baz.ext
基本上任何东西都会返回 IP 地址。如果需要,我可以自己处理 URI 解析(因此在查找时它是一致的格式),但这是一个额外的优点。
I basically want to implement something where you can type in any URI ( I probably will only deal with http ) and I want to return the A record of the domain in the URI, I want the server's IP address.
I know there's the ping command which most people use to look an ip address up, but I also know there's 'host' and 'dig' which are more specific.
Are there any native functions I can use that will do this for me? And if so, how lenient is that function in terms of what URI string it accepts and the structure it's in? I want to throw it:
- http://foo.com
- www.foo.com
- http://foo.com/baz.ext
And have basically anything return an IP address. If need be I can take care of the URI parsing ( so it's a consistent format when looked up ) myself, that's an extra plus though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)