本文實例講述了Python簡單取得自身外網IP的方法。分享給大家供大家參考,具體如下:
#encoding=utf-8 #author: walker #date: 2016-03-07 #function: 获取自己的外网IP import requests from bs4 import BeautifulSoup #获取外网IP def GetOuterIP(): url = r'http://www.whereismyip.com/' r = requests.get(url) bTag = BeautifulSoup(r.text, 'html.parser', from_encoding='utf-8').find('b') ip = ''.join(bTag.stripped_strings) print('ip:' + ip) if __name__ == '__main__': GetOuterIP()
#更多Python簡單取得自身外網IP的方法相關文章請關注PHP中文網!
#