
#@Siftware PyCharm
import wad.detection
# wad -u'https://www.baidu.com' # 報錯
det = wad.detection.Detector()
url = input()
print(det.detect(url))
錯誤如下
ERROR:root:Error while reading JSON file, terminating: 'gbk' codec can't decode byte 0xa1 in position 2638: illegal multibyte sequence
Traceback (most recent call last):
File "G:/Pycharm/demo_01/Zjc01/wad_detect.py", line 9, in <module>
det = wad.detection.Detector()
File "G:\Pycharm\demo_01\Zjc01\venv\lib\site-packages\wad\detection.py", line 24, in __init__
self.apps, self.categories = Clues.get_clues()
File "G:\Pycharm\demo_01\Zjc01\venv\lib\site-packages\wad\clues.py", line 38, in get_clues
self.load_clues(filename)
File "G:\Pycharm\demo_01\Zjc01\venv\lib\site-packages\wad\clues.py", line 94, in load_clues
self.apps, self.categories = self.read_clues_from_file(filename)
File "G:\Pycharm\demo_01\Zjc01\venv\lib\site-packages\wad\clues.py", line 55, in read_clues_from_file
clues = json.load(json_data)
File "G:\Python\lib\json\__init__.py", line 293, in load
return loads(fp.read(),
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa1 in position 2638: illegal multibyte sequence
,代碼目的是查看網站所用技術,報錯怎么解決。
uj5u.com熱心網友回復:
找了好多方法都不行。。uj5u.com熱心網友回復:
這個是 wad 這個庫的問題,應該是好久沒更新了,可以通過修改底層原始碼的方式解決,打開 clues.py(在 pycharm 里面直接點擊報錯的那個檔案就會直接跳到 clues.py),修改第 46 行代碼,加一個 utf-8 編碼就行了。
測驗代碼:
import wad.detection
det = wad.detection.Detector()
url = "https://www.baidu.com"
json_data = det.detect(url)
print(json_data)
運行結果如下:
uj5u.com熱心網友回復:
運行結果如下
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/284563.html
上一篇:如何讀取一個圖片檔案到buffer,并將buffer指標賦值給ctypes.c_void_p
下一篇:求學生考試作弊資料集

