dongyunque2511 2015-07-29 19:58
浏览 27
已采纳

是否可以检索附加到推文的gif?

I'm searching tweets through Twitter API with this endpoint

I'm testing with my own account. I tweeted a gif. But when I retrieve the json, I don't see the link of the attached media. It's automatically format in an url.

My aim is to store locally the images attached to tweets.

  • 写回答

1条回答 默认 最新

  • dongyu9667 2015-07-30 10:53
    关注

    Yes, it is possible. If you are looking for animated GIFs, you need to look in the extended_entities - here's an example:

    "extended_entities": { "media": [ { "id": 626705406224658400, "id_str": "626705406224658432", "indices": [ 29, 51 ], "media_url": "http://pbs.twimg.com/tweet_video_thumb/CLKBPxzWcAAFhYz.png", "media_url_https": "https://pbs.twimg.com/tweet_video_thumb/CLKBPxzWcAAFhYz.png", "url": "http://t.co/psSAzQfcFu", "display_url": "pic.twitter.com/psSAzQfcFu", "expanded_url": "http://twitter.com/edent/status/626705407550078976/photo/1", "type": "animated_gif",

    See! It tells you that there is an aGIF. Later on, you'll see the URL to directly download it.

    "sizes": { "small": { "w": 14, "h": 14, "resize": "fit" }, "medium": { "w": 14, "h": 14, "resize": "fit" }, "thumb": { "w": 14, "h": 14, "resize": "crop" }, "large": { "w": 14, "h": 14, "resize": "fit" } }, "video_info": { "aspect_ratio": [ 1, 1 ], "variants": [ { "bitrate": 0, "content_type": "video/mp4", "url": "https://pbs.twimg.com/tweet_video/CLKBPxzWcAAFhYz.mp4" } ] } } ] },

    Now, you can't download the GIF directly, but you can grab the video version of it.

    If you want other imgage (JPG, PNG, etc) take a look for the "media_url_https" field.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错