在微软必应网站上获取高清网页背景图
By:Roy.LiuLast updated:2021-03-11
做网页,有一张漂亮的高清背景图是一件赏心悦目的事。微软必应就有这样的服务,隔一段时间变化一个背景图,看起来很不错。可以通过如下地址请求拿到背景图片地址:
https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US
请求的结果如下:
{images: [ ], startdate: "20210311", fullstartdate: "202103110800", enddate: "20210312", url: "/th?id=OHR.CapePerpetua_EN-CN1657098545_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp", urlbase: "/th?id=OHR.CapePerpetua_EN-CN1657098545", copyright: "Thor's Well at Cape Perpetua on the Oregon coast (© Cavan Images/Offset by Shutterstock)", copyrightlink: "https://www.bing.com/search?q=thor%27s+well+oregon&form=hpcapt&filters=HpDate%3a%2220210311_0800%22", title: "Welcome to the 'drainpipe of the Pacific'", quiz: "/search?q=Bing+homepage+quiz&filters=WQOskey:%22HPQuiz_20210311_CapePerpetua%22&FORM=HPQUIZ", wp: true, hsh: "3bc4d4f0735db9ba4f39c4b7f377b3a8", drk: 1, top: 1, bot: 1, hs: [ ] { } tooltips: { } loading: "Loading...", previous: "Previous image", next: "Next image", walle: "This image is not available to download as wallpaper.", walls: "Download this image. Use of this image is restricted to wallpaper only." }
然后只要取到images[0].url 就得到图片地址了,请求这个地址,每隔一段时间图片会变化. 然后用javascript或者其他方式,就可以直接在页面设置背景图了。背景图的地址就是:
https://www.bing.com/ + images[0].url
From:一号门
COMMENTS