Downloading the top comments for an imgur image (jpg)
<p>How can I access the comments related to an imgur image using json? </p>

<p>for <a href="http://imgur.com/gallery/DVNWyG8" rel="nofollow">http://imgur.com/gallery/DVNWyG8</a> , browsing to <a href="http://api.imgur.com/3/image/DVNWyG8.json" rel="nofollow">http://api.imgur.com/3/image/DVNWyG8.json</a> yields:</p>

<pre><code>{"data":{"id":"DVNWyG8","title":"Fiber optic dress","description":null,"datetime":1476709283,"type":"image\/jpeg","animated":false,"width":2056,"height":1694,"size":482983,"views":1883274,"bandwidth":909589326342,"vote":null,"favorite":false,"nsfw":false,"section":"pics","account_url":null,"account_id":null,"is_ad":false,"in_gallery":true,"link":"http:\/\/i.imgur.com\/DVNWyG8.jpg"},"success":true,"status":200}
</code></pre>

<p>Also I can't wget it as I get this error:</p>

<pre><code>wget http://api.imgur.com/3/image/DVNWyG8.json
--2016-10-17 19:55:48--  http://api.imgur.com/3/image/DVNWyG8.json
Resolving api.imgur.com (api.imgur.com)... 151.101.44.193
Connecting to api.imgur.com (api.imgur.com)|151.101.44.193|:80... connected.
HTTP request sent, awaiting response... 400 Bad Request
2016-10-17 19:55:48 ERROR 400: Bad Request.
</code></pre>

<p>Basically I want to download an Imgur image with its top 30 comments. I wonder if I should do something with its json or if there's a neat Python API for this purpose? </p>

<p>Even using the API, I don't see the method for getting all the comments related to an image:</p>

<pre><code>  9 imgur_client = ImgurClient(client_id, client_secret, access_token, refresh_token)
 10 
 11 image = imgur_client.get_image("S1jmapR")
 12 print(image.title)
 13 print(image.link)
 14 print(dir(image))
</code></pre>

<p>I get:</p>

<pre><code>mona@pascal:~/computer_vision/imgur$ 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
Cat Ying &amp; Yang
http://i.imgur.com/S1jmapR.jpg
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'account_id', 'account_url', 'animated', 'bandwidth', 'datetime', 'description', 'favorite', 'height', 'id', 'in_gallery', 'is_ad', 'link', 'nsfw', 'section', 'size', 'title', 'type', 'views', 'vote', 'width']
mona@pascal:~/computer_vision/imgur$ vi download.py
</code></pre>

<p>As you see image has no comment method or get_comment.</p>

<pre><code> 21 for item in imgur_client.gallery_item_comments("c1SN8", sort='best'):
 22     print item.comment
</code></pre>

<p>Will do the job</p>

python json web-scraping imgur