Raise ImgurClientError('JSON Decoding Of Response Failed.') Imgurpython.helpers.error.ImgurClientError: JSON Decoding Of Response Failed
For the code below: 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
Solution 1:
Maybe not the best solution but this solved the problem:
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
Post a Comment for "Raise ImgurClientError('JSON Decoding Of Response Failed.') Imgurpython.helpers.error.ImgurClientError: JSON Decoding Of Response Failed"