MCPcopy Create free account
hub / github.com/EASY233/Finger / IpAttributable

Class IpAttributable

lib/ipAttributable.py:10–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class IpAttributable:
11 def __init__(self):
12 dbFile = os.path.join(path.library, "data", "ip2region.db")
13 self.searcher = Ip2Region(dbFile)
14 self.getAttributable()
15
16
17 def ipCollection(self):
18 ip_list = []
19 for value in Webinfo.result:
20 if value["iscdn"] == 0 and value["ip"] not in ip_list:
21 ip_list.append(value["ip"])
22 return ip_list
23
24 def getAttributable(self):
25 ips = self.ipCollection()
26 try:
27 for ip in ips:
28 addr = []
29 data = str(self.searcher.binarySearch(ip)["region"].decode('utf-8')).split("|")
30 isp = data[4].replace("0", "")
31 data.pop(4)
32 data.pop(1)
33 for ad in data:
34 if ad != "0" and ad not in addr and "" != ad:
35 addr.append(ad)
36 address = ','.join(addr)
37 for value in Webinfo.result:
38 if value['ip'] == ip:
39 Webinfo.result[Webinfo.result.index(value)]["address"] = address
40 Webinfo.result[Webinfo.result.index(value)]["isp"] = isp
41 except Exception as e:
42 pass
43

Callers 1

Finger.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected