Hebe ImgurClientError an ('JSON-Decodierung der Antwort fehlgeschlagen') imgurpython.helpers.error.ImgurClientError: JSON Decodierung der Antwort fehlgeschlagen

Für den folgenden Code:

12 imgur_client = ImgurClient(client_id, client_secret, access_token, refresh_token) 13 for p in range(100, 500): 14 search = imgur_client.gallery_search('cat', window='all', sort='time', page=p) 15 for i in range(0, len(search)): 16 #print(search[i].link) 17 #print(dir(search[i])) 18 print(search[i].type) 19 if search[i].comment_count > 30 and search[i].type!='gif': 20 count = 0 21 image_file = urllib2.urlopen(search[i].link, timeout = 5) 22 image_file_name = 'images/'+ search[i].id+search[i].type 23 output_image = open(image_file_name, 'wb') 24 output_image.write(image_file.read()) 25 26 for post in imgur_client.gallery_item_comments(search[i].id, sort='best'): 27 if count <= 30: 28 count += 1 29 

Ich bekomme :

  • Brauchen Sie Rat, um exponenital Back-off-Logik in AWS API in Python hinzuzufügen
  • Beste Weg, um xml zu generieren?
  • So senden Sie Nachricht mit @ID Telegramm mit Telethon-Bibliothek
  • Google-Suche gibt keine 302 auf AppEngine zurück
  • Sind Python-Fehlernummern mit IOError stabil verbunden?
  • HTMLParser in Python effizient nutzen
  •  $ python download.py /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning /usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning Traceback (most recent call last): File "download.py", line 14, in <module> search = imgur_client.gallery_search('cat', window='all', sort='time', page=p) File "/usr/local/lib/python2.7/dist-packages/imgurpython/client.py", line 531, in gallery_search response = self.make_request('GET', 'gallery/search/%s/%s/%s' % (sort, window, page), data) File "/usr/local/lib/python2.7/dist-packages/imgurpython/client.py", line 158, in make_request raise ImgurClientError('JSON decoding of response failed.') imgurpython.helpers.error.ImgurClientError: JSON decoding of response failed. 

    Können Sie bitte vorschlagen fixes?

  • Zugriff auf Klassenvariablen aus einem Listenverständnis in der Klassendefinition
  • Python: Erweiterte Verschachtelte List-Verständnis-Syntax
  • Python local vs globale Variablen
  • Python globale Variable Scoping
  • NameError mit execfile in python
  • Variablenbereich in verschachtelten Funktionen
  • One Solution collect form web for “Hebe ImgurClientError an ('JSON-Decodierung der Antwort fehlgeschlagen') imgurpython.helpers.error.ImgurClientError: JSON Decodierung der Antwort fehlgeschlagen”

    Vielleicht nicht die beste Lösung, aber das hat das Problem gelöst:

      1 from imgurpython import ImgurClient 2 import inspect 3 import random 4 import urllib2 5 import requests 6 from imgurpython.helpers.error import ImgurClientError 15 imgur_client = ImgurClient(client_id, client_secret, access_token, refresh_token) 16 17 for p in range(100, 500): 18 try: 19 search = imgur_client.gallery_search('cat', window='all', sort='time', page=p) 20 for i in range(0, len(search)): 21 if search[i].comment_count > 30 and not search[i].is_album: 22 print(search[i].type) 23 if 'jpg' in search[i].type : 24 count = 0 25 image_file = urllib2.urlopen(search[i].link, timeout = 5) 26 image_file_name = 'images/'+ search[i].id+'.'+search[i].type[6:] 27 output_image = open(image_file_name, 'wb') 28 output_image.write(image_file.read()) 29 for post in imgur_client.gallery_item_comments(search[i].id, sort='best'): 30 if count <= 30: 31 count += 1 32 except ImgurClientError as e: 33 print(e) 34 continue 
    Python ist die beste Programmiersprache der Welt.