在python获取网址的IP地址? [英] Get IP address of url in python?
问题描述
可能重复:结果
<一href=\"http://stackoverflow.com/questions/2805231/how-can-i-do-dns-lookups-in-python-including-referring-to-etc-hosts\">How我可以做在Python DNS查找,其中涉及到/ etc / hosts文件?
块引用>即时通讯使用Python 2.7和IM与创建一个在线的API一个iptracer。
,我想用户必须键入如google.com, http://google.com 或www.google.com选项然后得到的IP地址和IP地址添加到一个变量。
时的任何链接或其他帮助,任何人都可以给我吗?
-stian
解决方案&GT;&GT;&GT;进口插座
&GT;&GT;&GT;打印socket.gethostbyname('google.com')
74.125.236.52Possible Duplicate:
How can I do DNS lookups in Python, including referring to /etc/hosts?Im using Python 2.7 and im creating a iptracer with an online API.
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获取网址的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!