Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12db3bf

Browse files
authored
Create get_local_wip.py
1 parent b9dcee6 commit 12db3bf

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

get_local_wip.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#encoding: utf-8
2+
import requests
3+
from bs4 import BeautifulSoup
4+
5+
6+
# 获取公网出口IP
7+
def get_out_ip(url):
8+
r = requests.get(url)
9+
txt = r.text
10+
ip = txt[txt.find("[") + 1: txt.find("]")]
11+
print('ip:' + ip)
12+
return ip
13+
14+
15+
def get_real_url(url=r'http://www.ip138.com/'):
16+
r = requests.get(url)
17+
txt = r.text
18+
soup = BeautifulSoup(txt,"html.parser").iframe
19+
return soup["src"]
20+
21+
22+
if __name__ == '__main__':
23+
ip = get_out_ip(get_real_url())
24+
with open("result.log", "a") as f:
25+
print >>f, ip
26+
27+
#pip install pyinstaller
28+
#pyinstaller -F get_local_wip.py >> dist/get_local_wip.exe

0 commit comments

Comments
 (0)