Power BI动态获取每日必应图片背景
本文分享Power BI 趣味应用之动态获取每日必应图片背景。

经常用必应搜索的朋友大都非常喜欢必应的每日图片,也有人用来做桌面壁纸。今天我们一起看一下如何通过Power BI 将每天的必应图片调用到我们的报表中作为背景或配图,这样每次刷新报表的时候,图片都会发生变化,也是很有趣的一件事情。
调用的核心是找到必应图片的网络地址,这个可以通过网络搜索快速找到解决方法:
我们可以访问:http://cn.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1获得一个XML文件,里面包含了图片的地址。直接访问该网址可以得到如下结果:

绿色框线内为当天的必应图片地址,但该地址不完全,需要添加前缀:http://s.cn.bing.net 得到完整的当日图片地址。
(上述方法来自网络搜索TheOneGIS的博客)
是不是已经想到了完成方法?我们来看一下完整Power BI 自动获取过程:
在Power BI 桌面版中选择“获取数据” - “从Web” , 然后输入 http://cn.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1

点击确定后,选择“Image“ ,然后”编辑“

选中我们需要的url 列,点击选择“删除其它列“

“转换“菜单下, “格式”里选择“添加前缀”,

输入http://s.cn.bing.net,这样我们就得到了完整的图片地址。当然,这一步也可以用自定义列的方式实现。

点击 “关闭并应用”进行加载。为了更好的呈现图片效果,我们导入并使用自定义可视化对象 - Img Viewer 。最终得到如下图片效果:

关于自定义可视化图表请参考之前的推文 :
亮瞎双眼的Power BI 自定义可视化图表
这样我们以后每天刷新就可以得到当天的必应图片了,是不是非常有趣?
不仅如此,我们在最开始输入的网址:
http://cn.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1中的 idx=0 代表当天的图片,如果我们把0改成 -1, 则代表预备用于明天的图片。我们在查询编辑器里更改一下并刷新看看明天必应的图片是什么?

很漂亮的风景,这是哪里呢?你可能注意到了,在我们抓取图片地址的时候,里面还包含了一些其它信息,比如图片的名称和版权信息(要注意版权问题哦)。所以明天必应的图片为苏丹的麦罗埃遗迹中的金字塔群。

同样的道理,如果我们把idx=0 变成 idx=1,则是昨天的图片:

依此类推,最多可以抓到过去7天的图片。

这就是今天的分享内容,感兴趣的话自己动手试试吧。也期待您留言分享更多有趣的Power BI 应用场景。
如果您想深入学习微软Power BI,欢迎登录网易云课堂试听学习我们的“从Excel到Power BI数据分析可视化”系列课程。或者关注我们的公众号(PowerPivot工坊)后猛戳”在线学习”

长按下方二维码关注“Power Pivot工坊”获取更多微软Power BI、Power Pivot相关文章、资讯。欢迎小伙伴儿们转发分享~
