logo
Loading...

使用 requests 的結果轉成.text出現JSONDecodeError: Expecting value: line 1 column 1 (char 0) - Cupoy

JSONDecodeError: Expecting value: line 1 column 1 ...

pycrawler,pycrawler-d08

使用 requests 的結果轉成.text出現JSONDecodeError: Expecting value: line 1 column 1 (char 0)

2019/12/04 下午 02:55
Python網路爬蟲討論版
林辰
觀看數:7
回答數:1
收藏數:1
pycrawler
pycrawler-d08

JSONDecodeError: Expecting value: line 1 column 1 (char 0)


requests 的結果轉乘.text有時候不能直接丟入json, 有時候會報出以上錯誤, 請問要怎麼處理比較好? 

回答列表

  • 2019/12/04 下午 09:55
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:0
    留言數:0

    嗨,原因是這個 response 並不是 JSON 格式,他是 HTML 的格式。所以必須用其它套件才能解析。