0
在使用Python包裝器構建Onionscan Scraper之後,我最近試圖使用Onionscan後tutorial。自從編寫教程以來,Onionscan已經從將所有數據存儲在JSON文件中轉移到將其中一些存儲在使用Tiedot構建的數據庫中。使用Python從Onionscan讀取原始數據(二進制?)Tiedot(NOSQL/JSON)數據
我想找到一種方法,將其中一個沒有擴展名的文件取名爲dat_0
並使用Python對其進行解析。
在MacOS上的TextEdit我得到以下看着dat_0
...
我一直在試圖找出如何解析這個文件使用Python。我假設Tiedot的文檔和通過Textedit的視圖使用JSON結構,但我沒有太多的運氣。
import json
f = open('crawls/dat_0','rb')
data = json.dumps(f.read())
IOPub data rate exceeded.
The notebook server will temporarily stop sending output
to the client in order to avoid crashing it.
To change this limit, set the config variable
`--NotebookApp.iopub_data_rate_limit`.
或
data = json.loads(f.read())
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-21c335a72c11> in <module>()
----> 1 data = json.loads(f)
/Users/James/anaconda/lib/python3.5/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
310 if not isinstance(s, str):
311 raise TypeError('the JSON object must be str, not {!r}'.format(
--> 312 s.__class__.__name__))
313 if s.startswith(u'\ufeff'):
314 raise JSONDecodeError("Unexpected UTF-8 BOM (decode using utf-8-sig)",
TypeError: the JSON object must be str, not 'bytes'
有誰...... 一)知道這個文件是什麼? b)知道如何成功地解析它以使數據在Python中可用?
爲什麼會出現在你的問題中去標籤?您在Python中尋求幫助,事實上OnionScan是用Go編寫的,與您的問題無關。 –
@WilliamPoussier我並不完全確定我試圖解析的數據是否是Go社區中相當標準的格式,因爲它是使用Tiedot生成的。我認爲如果是這樣的話,那些熟悉Go的人會很快得到認可,但不一定是那些熟悉Python的人。 –