일부 URL을 살펴보고 사용중인 API에서 대부분의 데이터를 가져올 수 있습니다. * Imgur API. 그 전에 게시되어 결국 제거 된 이미지를 발견하지만 때 여전히 긍정적 인 URL은 응답 (코드 200)를 얻을 보여주고, 내가ValueError : JSON 객체가 디코딩 될 수는 없지만 양수 일 수 있습니다. <Response [200]>
j1 = json.loads(r_positive.text)
를 사용할 때이 오류가 얻을 :
http://imgur.com/gallery/cJPSzbu.json
<Response [200]>
Traceback (most recent call last):
File "image_poller_multiple.py", line 61, in <module>
j1 = json.loads(r_positive.text)
File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
을
대신 j1 변수에서 오류를 "가져올"수 있습니까? 조건 구조를 사용하여 문제를 해결하고 내 프로그램이 충돌하지 않도록하고 싶습니다.
if j1 == ValueError:
continue
else:
do_next_procedures()
귀하의 예를 들어 URL이 http://imgur.com/cJPSzbu에 나를 리디렉션, 나에게 발견 (302)을 제공합니다. 200 OK라고 확신합니까? – Fabian