在python中获取url的IP地址? [英] Get IP address of url in python?

查看:22
本文介绍了在python中获取url的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
我如何进行 DNS 查找在 Python 中,包括引用/etc/hosts?

我使用 Python 2.7,并使用在线 API 创建了一个 iptracer.

Im using Python 2.7 and im creating a iptracer with an online API.

而且我希望用户可以选择输入例如 google.com、http://google.com 或www.google.com 然后获取它的 ip 地址并将该 ip 添加到变量中.

And i want the user to have the option to type e.g google.com, http://google.com or www.google.com and then get the ip address of that and add the ip to a variable.

任何人都可以给我任何链接或其他帮助吗?

Is it any links or other help anyone can give me?

-stian

推荐答案

>>> import socket
>>> print socket.gethostbyname('google.com')
74.125.236.52

这篇关于在python中获取url的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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