forked from but3k4/botcha
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathipinfo.py
More file actions
26 lines (22 loc) · 745 Bytes
/
ipinfo.py
File metadata and controls
26 lines (22 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
#
from lib.modules.web import Web
import re
def ipinfo(args):
try:
web = Web()
uri = 'http://whatismyipaddress.com/ip/'
answer = web.html(web.get(uri + args))
return answer
th = answer.findAll('th')
td = answer.findAll('td')
infos = []
for x in range(len(td)):
key = th[x].string.lower().strip()
value = re.sub('\([^()]+\)', '', re.sub('<[^<>]*>', '', str(td[x])).strip('\n').replace(' ', '').strip())
if not value.startswith('None') and len(value):
infos.append("%s %s" % (key, value))
return ', '.join(infos)
except Exception, e:
return repr(e)
print ipinfo('8.8.8.8')