0
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
я получаю:
$ 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.
Можете ли вы предложить исправления?