获取随机图片的API-亲测可行

获取随机图片的API

在个人博客或者一些web页面中,我们可能想让背景是随机图片。这里有两种方法:

一种是使用现有的随机图片API,另一种就是在服务器端准备好图片,随机展示。

URL的使用方法是img标签嵌入到网页中。

随机图片API *3

效果展示网址:https://xubean.top/

  1. bing的github API
    功能: 来自github的项目 https://github.com/xCss/bing
    地址: https://bing.ioliu.cn/v1/rand (返回随机图片)

    如需指定大小: https://bing.ioliu.cn/v1/rand?w=1920&h=1200

/**
 * 已知分辨率
 */
resolutions: [
    '1920x1200',
    '1920x1080',
    '1600x800',
    '1366x768',
    '1280x768',
    '1024x768',
    '800x600',
    '800x480',
    '768x1280',
    '720x1280',
    '640x480',
    '480x800',
    '400x240',
    '320x240',
    '240x320'
]
  1. Bing 每日一图接口

    随机图片:

    http://bing.yingjoy.cn/?t=random&w=1920
    

    每日一图(以1920x1080举例)

    http://bing.yingjoy.cn/?t=bing&w=1920
    

    可用分辨率如上

    参数 说明
    t 类型
    w 宽度
    h 高度

    t 有两种类型: bing 和 random

    扫描二维码关注公众号,回复: 10365736 查看本文章

    bing: 获取Bing每日图片

    random: 获取随机图片

  2. uploadbeta.com

功能: 返回Bing的随机图片
地址: https://uploadbeta.com/api/pictures/random/?key=BingEverydayWallpaperPicture

服务器端保存图片

后续更新…

发布了92 篇原创文章 · 获赞 57 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/xbean1028/article/details/105111826