引发JSONDecodeError:预期值:第2行第1列(字符1)

时间:2019-01-22 15:18:31

标签: python json python-3.x web-crawler jupyter-notebook

我正在尝试使用Python来爬行Amazon Web上的信息并发现此问题。

这是我的代码。

import requests
import json

url = 'https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=ssd'
res = requests .get(url)
data = json.loads(res.text)
data

这是结果。

JSONDecodeError   Traceback (most recent call last)
<ipython-input-13-4d0bdc7a5077> in <module>
  1 url = 'https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=ssd'
  2 res = requests .get(url)
----> 3 data = json.loads(res.text)

/anaconda3/lib/python3.7/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
346             parse_int is None and parse_float is None and
347             parse_constant is None and object_pairs_hook is None and not kw):
--> 348         return _default_decoder.decode(s)
349     if cls is None:
350         cls = JSONDecoder

/anaconda3/lib/python3.7/json/decoder.py in decode(self, s, _w)
335 
336         """
--> 337         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338         end = _w(s, end).end()
339         if end != len(s):


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

0 个答案:

没有答案