在Python中找到面向公众的IP地址? [英] Finding a public facing IP address in Python?
本文介绍了在Python中找到面向公众的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Python网络中找到面向公众的IP?
How can I find the public facing IP for my net work in Python?
推荐答案
这将获取您的远程IP地址
This will fetch your remote IP address
import urllib
ip = urllib.urlopen('http://automation.whatismyip.com/n09230945.asp').read()
如果您不想依赖其他人,则只需上传类似以下PHP脚本的内容:
If you don't want to rely on someone else, then just upload something like this PHP script:
<?php echo $_SERVER['REMOTE_ADDR']; ?>
并在Python中更改URL,或者如果您更喜欢ASP,则更改:
and change the URL in the Python or if you prefer ASP:
<%
Dim UserIPAddress
UserIPAddress = Request.ServerVariables("REMOTE_ADDR")
%>
注意:我不知道ASP,但是我认为在这里安装它可能会有用,所以我用谷歌搜索.
Note: I don't know ASP, but I figured it might be useful to have here so I googled.
这篇关于在Python中找到面向公众的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文