我正在尝试使用request
从网站列表中获取年龄,如下所示:
import json
import requests
my_list=['www.expedia.it', 'www.fortuneita.com', 'www.finanzaonline.com', 'it-it.facebook.com', 'www.capterra.it', 'www.sportmediaset.mediaset.it', 'www.incredibile.net', 'www.newsrimini.it', 'web.tiscali.it', 'www.dettiescritti.com']
api_url = 'https://web.archive.org/__wb/search/metadata'
for url in my_list:
data = requests.get(api_url, params={'q': url}).json()
min_year = min(data['urls'], key=int)
但是我遇到了这个错误:
JSONDecodeError Traceback (most recent call last)
<ipython-input-27-e091c19d8374> in <module>
15 for url in my_list:
---> 16 data = requests.get(api_url, params={'q': url}).json()
/anaconda3/lib/python3.7/site-packages/requests/models.py in json(self, **kwargs)
896 # used.
897 pass
--> 898 return complexjson.loads(self.text, **kwargs)
899
900 @property
/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):
/anaconda3/lib/python3.7/json/decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
我查看了以下问题:JSONDecodeError: Expecting value: line 1 column 1 (char 0) 但是我没有解决这个问题的方法。
您知道我该如何解决吗?几分钟前一切正常,我没有做任何更改。