Git Product home page Git Product logo

wonderful-bing-wallpaper's Introduction

GitHub stars Build Status GitHub issues GitHub forks GitHub last commit license Twitter

NPM NPM

wonderful-bing-wallpaper

🌅A simple bing daily wallpaper api lib. 极简的 Node.js 版必应壁纸 API 库。

  • 简单:1 个接口
  • 稳定:与 Bing 同在
  • 轻巧:不依赖任何第三方

贡献者

stackoverflow - Is there a way to get Bing's photo of the day?

实例

example.js

Online site - example - 山河入梦

怎么用

npm i wonderful-bing-wallpaper --save
// require
const WonderfulBingWallpaper = require('wonderful-bing-wallpaper')

// get support resolutions list
const resolutions = WonderfulBingWallpaper.resolutions

// instance
const wbw = new WonderfulBingWallpaper(options)

// update default options
wbw.setOptions(options)

// get daily wallpapers
wbw.getWallpapers(params).then(wallpaperJSON => {
  console.log('got wallpaperJSON data', wallpaperJSON)
  console.log('got humanizeWallpapers data - Array', wbw.humanizeWallpapers(wallpaperJSON))
  console.log('got humanizeWallpapers data - Object', wbw.humanizeWallpapers(wallpaperJSON[0]))
})

// get today wallpaper story
wbw.getTodayWallpaperStory().then(todayWallpaperStory => {
    console.log('todayWallpaperStory', todayWallpaperStory)
})

API

new WonderfulBingWallpaper(options?: object): instance

wbw.setOptions(options?: object): instance

@return WonderfulBingWallpaper instance

recommended option field(推荐设置的字段)

params type required default desc
size Number false 1 how many images - 几张图片 size <= 8
day Number false 0 how days before - 往前推几天 day <= 7
format String false js result data format - 返回数据的格式 js/xml/rss
local String false en-US your location - 你想拿到什么语言的版本(国内 zh-CN

not recommended option field(非必要情况不要设置的字段)

params type required default desc
host String false www.bing.com bing wallpaper api host
你想在哪个服务器拿数据(国内 cn.bing.com
wallpaperApi String false /HPImageArchive.aspx bing wallpaper api path
如果哪天 Bing 改接口了你可以手动设置一下
storyApi String false /cnhp/coverstory/ bing wallpaper story api path
今日壁纸故事 API,只能获取今天
resolution String false 1920x1200 humanizeWallpapers second param default resolution
使用 humanizeWallpapers 方法时第二参数的默认值

wbw.getWallpapers(params?: object): array

@return wallpaper array

the same as Options - recommended option field


wbw.humanizeWallpapers(wallPapers: object | array, resolution?: string): array

@return humanize wallpaper array

params type required default desc
wallPapers Array/Object true null wallpaper images
图片或多张图片
resolution String false {instance}.options.resolution wallpaper resolution
要输出的图片地址里的分辨率

wbw.getTodayWallpaperStory(): object

@return wallpaper story object


测试执行

npm i
npm run dev
npm run test

Author

Surmon

wonderful-bing-wallpaper's People

Contributors

torvaldssg avatar surmon-china avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.