获取每日bing壁纸

2023-12-18 11:53:24

在线查看

public void loadBingWallPaper() {
        String result = HttpUtil.get("https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1");
        if (result != null && JSONUtil.isJson(result)) {
            Map map = JSONUtil.toBean(result, Map.class);
            if (CollUtil.isNotEmpty(map)) {
                String images = String.valueOf(map.get("images"));
                if (StrUtil.isNotBlank(images)) {
                    Map<String, Object> image = (Map<String, Object>) JSONUtil.parseArray(images).get(0);
                    BingWallpaper wallpaper = BeanUtil.toBean(image, BingWallpaper.class);
                    String url = wallpaper.getUrl();
                    System.out.println("https://cn.bing.com" + url);
                }
            }
        }
    }

文章来源:https://blog.csdn.net/qq_27574367/article/details/135057333
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。