python獲取本機外網(wǎng)ip的方法
更新時間:2015年04月15日 12:31:33 作者:令狐不聰
這篇文章主要介紹了python獲取本機外網(wǎng)ip的方法,可實現(xiàn)從外網(wǎng)顯示IP的網(wǎng)站獲取本機IP的功能,非常具有實用價值,需要的朋友可以參考下
本文實例講述了python獲取本機外網(wǎng)ip的方法。分享給大家供大家參考。具體如下:
python從顯示ip地址的網(wǎng)站獲取本機外網(wǎng)ip,這段python代碼抓取網(wǎng)站上的ip地址信息
import urllib
import re
print "we will try to open this url, in order to get IP Address"
url = "http://checkip.dyndns.org"
print url
request = urllib.urlopen(url).read()
theIP = re.findall(r"\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}",request)
print "your IP Address is: ", theIP
希望本文所述對大家的Python程序設計有所幫助。
相關(guān)文章
python3通過selenium爬蟲獲取到dj商品的實例代碼
這篇文章主要介紹了python3通過selenium爬蟲獲取到dj商品的實例代碼,需要的朋友可以參考下2019-04-04
TensorFLow 不同大小圖片的TFrecords存取實例
今天小編就為大家分享一篇TensorFLow 不同大小圖片的TFrecords存取實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-01-01

