code say anything:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#encoding=utf-8
#author: walker
#date: 2016-03-07
#summary: 获取自己的外网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()
|
PS:2016年3月7号可用。
相关阅读:Python获取本机IP(多网卡)
*** walker ***
本文转自walker snapshot博客51CTO博客,原文链接http://blog.51cto.com/walkerqt/1748418如需转载请自行联系原作者
RQSLT