-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathiconhash.py
33 lines (28 loc) · 1.12 KB
/
iconhash.py
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
27
28
29
30
31
32
33
import requests
import base64
import mmh3
import threading
class IconHash:
def __init__(self, ui):
self.ui = ui
def icohash(self):
self.ui.textBrowser.clear()
your_search = self.ui.ico_hash.text()
self.ui.shuchu.append(f'iconhash正在查询 ==> {your_search},请稍后...' + '\n')
thread = threading.Thread(target=self.icohash_threadSend,
args=(your_search,))
thread.start()
def icohash_threadSend(self, your_search):
try:
r = requests.get(your_search)
favicon = base64.encodebytes(r.content)
hash = mmh3.hash(favicon)
result = 'icon_hash="{}"'.format(hash)
self.ui.textBrowser.append(result)
self.ui.shuchu.append(result + '\n')
self.ui.shuchu.append('icon_hash 已查询完成' + '\n' + '-' * 29)
print(result)
except requests.exceptions.MissingSchema as e:
self.ui.shuchu.append(str(e) + '\n' + '-' * 29)
except requests.exceptions.ConnectionError as e:
self.ui.shuchu.append(str(e) + '\n' + '-' * 29)