2016-10-18 4 views
0

jsonを使用してimgurイメージに関連するコメントにアクセスするにはどうすればよいですか? http://imgur.com/gallery/DVNWyG8ためimgurイメージ(jpg)のトップコメントをダウンロードする

http://api.imgur.com/3/image/DVNWyG8.json利回りにブラウジング:私はこのエラーを取得するよう

{"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} 

また、私はそれをwgetのことはできません。

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. 

基本的に私がその上でImgurイメージをダウンロードしたいです30コメント。もし私がそのjsonで何かをするべきか、あるいはこの目的のためにきちんとしたPython APIがあるのだろうか?

でも、私は画像に関連するすべてのコメントを取得するための方法で表示されていないAPIを使用して:

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)) 

を私が取得:

[email protected]:~/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 & 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'] 
[email protected]:~/computer_vision/imgur$ vi download.py 

あなたはイメージが全くコメントがありません見ての通りメソッドまたはget_comment

答えて

1
21 for item in imgur_client.gallery_item_comments("c1SN8", sort='best'): 
22  print item.comment 

+0

はい、ドキュメント内のメソッドは画像オブジェクトではなくimgur_clientに属しています – Juggernaut

0

このPythonのライブラリはここにあなたのニーズに合った、https://github.com/Imgur/imgurpython

+0

が更新質問 –

+0

@MonaJalal何about'get_comment(comment_idを) 'を参照してください仕事をするだろうか? – Juggernaut

+0

'get_comment(comment_id)'が 'ImgurClient'のメソッド – Juggernaut

関連する問題