有没有办法获得Bing当天的照片?

时间:2012-05-17 16:44:57

标签: bing

有没有办法以编程方式获取Bing背景图片?

Bing的API似乎没有提供这样的功能,也许还有另一种方式?

22 个答案:

答案 0 :(得分:104)

我认为最好的方法是通过他们的AJAX调用来模仿他们自己做的方式。

他们调用此URL并通过XML反序列化提取信息。

XML: http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=en-US

JSON: http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US

RSS: http://www.bing.com/HPImageArchive.aspx?format=rss&idx=0&n=1&mkt=en-US

mkt属性显然可以更改为与'en-US'不同的区域,但如果您不关心特定区域,也可以完全取消选择。

请注意,添加到图片名称的_1366x768.jpg后缀似乎可以修改为不同的分辨率(如全高清_1920x1080.jpg以及其他可能的其他分辨率。)

以下是截至2013年9月28日的数据转储,采用XML格式。

<?xml version="1.0" encoding="utf-8"?>
<images>
    <image>
        <startdate>20130928</startdate>
        <fullstartdate>201309280000</fullstartdate>
        <enddate>20130929</enddate>
        <url>/az/hprichbg/rb/LakeTurkana_EN-US15976511099_1366x768.jpg</url>
        <urlBase>/az/hprichbg/rb/LakeTurkana_EN-US15976511099</urlBase>
        <copyright>Lava rock pools at the southern end of Lake Turkana, in Kenya (© Nigel Pavitt/Corbis)</copyright>
        <copyrightlink>http://www.bing.com/search?q=Lake+Turkana%2C+Kenya&amp;form=hpcapt</copyrightlink>
        <drk>1</drk>
        <top>1</top>
        <bot>1</bot>
        <hotspots>
            <hotspot>
                <desc>These are the southern reaches of a lake...</desc>
                <link>http://www.bing.com/maps/?v=2&amp;cp=2.794725~37.335197&amp;lvl=7&amp;dir=0&amp;sty=b&amp;q=Lake%20Turkana%2C%20Kenya&amp;form=hphot1</link>
                <query>That stretches for 180 miles, up into another country</query>
                <LocX>15</LocX>
                <LocY>33</LocY>
            </hotspot>
            <hotspot>
                <desc>This body of water was once called the Jade Sea.</desc>
                <link>http://www.bing.com/search?q=green+algae&amp;form=hphot2</link>
                <query>What gives the water here its sometimes vibrant hue?</query>
                <LocX>37</LocX>
                <LocY>42</LocY>
            </hotspot>
            <hotspot>
                <desc>One of the world's most powerful predators lives here.</desc>
                <link>http://www.bing.com/videos/search?q=Underwater+Croc+Cams+National+Geographic&amp;FORM=hphot3#view=detail&amp;mid=D25E1909D3514A8732C5D25E1909D3514A8732C5</link>
                <query>See some rare underwater footage of the beast</query>
                <LocX>66</LocX>
                <LocY>33</LocY>
            </hotspot>
            <hotspot>
                <desc>Many fossils of ancient human ancestors have been uncovered in the surrounding area.</desc>
                <link>http://www.bing.com/search?q=Turkana+Boy&amp;form=hphot4</link>
                <query>One skeleton was so complete, paleoanthropologists gave him a name</query>
                <LocX>82</LocX>
                <LocY>41</LocY>
            </hotspot>
        </hotspots>
        <messages></messages>
    </image>
    <tooltips>
        <loadMessage>
            <message>Indlæser...</message>
        </loadMessage>
        <previousImage>
            <text>Forrige</text>
        </previousImage>
        <nextImage>
            <text>Næste</text>
        </nextImage>
        <play>
            <text>Afspil</text>
        </play>
        <pause>
            <text>Pause</text>
        </pause>
    </tooltips>
</images>

答案 1 :(得分:28)

BING IMAGE的JSON格式

我找到了一种方法来获取当天 Bing图像 JSON格式

  

<强> http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1

注意

n=你想要的图像数量(你可以使用整数),
  mkt=你的    位置(例如: en-US

<小时/> 这是JSON输出,如

  {
  "images": [
    {
      "startdate": "20141214",
      "fullstartdate": "201412141830",
      "enddate": "20141215",
      "url": "\/az\/hprichbg\/rb\/BlackButte_EN-IN7038391888_1920x1080.jpg",
      "urlbase": "\/az\/hprichbg\/rb\/BlackButte_EN-IN7038391888",
      "copyright": "Black Butte, seen from the Mount Jefferson Wilderness, Oregon, USA (\u00a9 Marc Adamus\/Aurora Photos)",
      "copyrightlink": "http:\/\/www.bing.com\/search?q=Black+Butte&qs=n&form=hpcapt&mkt=en-in&pq=black+butte&sc=8-11&sp=-1&sk=&cvid=228ac7f125f94bbaafd4a4abd4f9a32d",
      "wp": true,
      "hsh": "94156ae1e2e1be49f9b739d2b7bff65c",
      "drk": 1,
      "top": 1,
      "bot": 1,
      "hs": [

      ],
      "msg": [
        {
          "title": "How does it feel\u2026",
          "link": "http:\/\/www.bing.com\/videos\/search?q=Climbing+Black+Butte&FORM=pgbar1&mkt=en-in#view=detail&mid=58BDB2F2B9FCB85D597558BDB2F2B9FCB85D5975",
          "text": "To climb 1961.7 m?"
        },
        {
          "title": "On top of the world",
          "link": "http:\/\/www.bing.com\/images\/search?q=Pictures+From+the+Top+of+Mount+Everest&FORM=pgbar2&mkt=en-in",
          "text": "It's mountaineer's dream view"
        }
      ]
    }
  ],
  "tooltips": {
    "loading": "Loading...",
    "previous": "Previous",
    "next": "Next",
    "walle": "This image is not available to download as wallpaper.",
    "walls": "Download this image. Use of this image is restricted to wallpaper only."
  }
}

使用url

中的images[]

并将其添加到'http://bing.com'

此处网址为"url": "\/az\/hprichbg\/rb\/DayGecko_EN-US8730336235_1366x768.jpg"

答案 2 :(得分:10)

Microsoft最近为Windows 7发布了Bing Dynamic Theme,其中包含an RSS Feed with links to Bing wallpapers

还有一个Python script尝试加载Bing网站并猜测正确的图片网址,但根据我的经验,它通常会导致图像分辨率低于RSS Feed提供的图像。

答案 3 :(得分:6)

我来晚了,但是如果有人需要PHP实现:我已经编写了一个处理程序的简单类:

https://github.com/grubersjoe/bing-daily-photo

答案 4 :(得分:5)

单线程PowerShell(3.0或更高版本)

$items = DB::table('items') ->leftjoin('item_images', function($join){ $join->on('item_images.item_id','=','items.id'); }) ->select('items.id', 'items.name', 'item_images.image_file') ->get() irm

的别名
Invoke-RestMethod

答案 5 :(得分:4)

我也喜欢Bing图片,但他们的应用程序过于臃肿,无法下载图像。在分析了与fiddler的连接后,我编写了这段代码。 1920x1200嵌入了Bing徽标,但较低的分辨率没有它。

您可以让窗口显示您设置的图像文件夹中的随机图像,以便每天下载它们时,它会向您显示更多随机图像。 如果您确实保留了&#34; imageDir&#34;,您需要更改该文件夹的权限,否则它将崩溃,我没有理会捕获错误。 最后,如果您想将壁纸设置为今天的图像,请取消注释这些线条,或者您可以创建一个任务来运行该程序,比如说登录后一分钟。

using System;
using System.IO;
using System.Net;
//using System.Runtime.InteropServices;

namespace Bing
{
    class Program
    {
      //  [DllImport("user32.dll", CharSet = CharSet.Auto)]
      //  private static extern Int32 SystemParametersInfo(UInt32 uiAction, UInt32 uiParam, String pvParam, UInt32 fWinIni);
        private static String imgDir = @"C:\Windows\Web\Wallpaper\Bing\";

        static void Main(string[] args)
        {
            String imageFileName;
            if (!Directory.Exists(imgDir))
                Directory.CreateDirectory(imgDir);

            for (byte i = 6; i >= 0; i--)
            {
                imageFileName = imgDir + DateTime.Today.AddDays(-i).ToString("yyy-MM-dd") + ".jpg";

                if (!File.Exists(imageFileName))
                {
                    string response = null;
                    Connect(ref response, i);
                    ProcessXml(ref response);
                    using (WebClient client = new WebClient())
                        client.DownloadFile("http://www.bing.com" + response + "_1920x1200.jpg", imageFileName);
                }                
            }
            //SystemParametersInfo(20, 0, imageFileName, 0x01 | 0x02);
        }

        private static void Connect(ref string res, byte i)
        {
            HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create("http://www.bing.com/hpimagearchive.aspx?format=xml&idx=" + i + "&n=1&mbl=1&mkt=en-ww");
            webrequest.KeepAlive = false;
            webrequest.Method = "GET";
            using (HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse())
                using (StreamReader loResponseStream = new StreamReader(webresponse.GetResponseStream()))
                    res = loResponseStream.ReadToEnd();                
        }

        private static void ProcessXml(ref string xmlString)
        {
            using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(new StringReader(xmlString)))
            {
                reader.ReadToFollowing("urlBase");
                xmlString = reader.ReadElementContentAsString();
            }
        }        
    }
}

答案 6 :(得分:3)

我看到很多人也在要求新的RSS链接,只需将URL中的format参数更改为“rss”。

RSS http://www.bing.com/HPImageArchive.aspx?format=rss&idx=0&n=1&mkt=en-US

答案 7 :(得分:2)

如果有人正在寻找可能的实现,我在C#中编写了一个小的命令行程序来下载,保存并设置我的背景作为当天的Bing图像。您可以根据自己的个人需求进行修改。 https://github.com/josueespinosa/BingBackground

using Microsoft.Win32;
using Newtonsoft.Json;
using System;
using System.Drawing;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace BingBackground
{
    class BingBackground
    {
        private static void Main(string[] args)
        {
            string urlBase = GetBackgroundUrlBase();
            Image background = DownloadBackground(urlBase + GetResolutionExtension(urlBase));
            SaveBackground(background);
            SetBackground(background, PicturePosition.Fill);
        }

        private static dynamic DownloadJson()
        {
            using (WebClient webClient = new WebClient())
            {
                Console.WriteLine("Downloading JSON...");
                string jsonString = webClient.DownloadString("https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US");
                return JsonConvert.DeserializeObject<dynamic>(jsonString);
            }
        }

        private static string GetBackgroundUrlBase()
        {
            dynamic jsonObject = DownloadJson();
            return "https://www.bing.com" + jsonObject.images[0].urlbase;
        }

        private static string GetBackgroundTitle()
        {
            dynamic jsonObject = DownloadJson();
            string copyrightText = jsonObject.images[0].copyright;
            return copyrightText.Substring(0, copyrightText.IndexOf(" ("));
        }

        private static bool WebsiteExists(string url)
        {
            try
            {
                WebRequest request = WebRequest.Create(url);
                request.Method = "HEAD";
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                return response.StatusCode == HttpStatusCode.OK;
            }
            catch
            {
                return false;
            }
        }

        private static string GetResolutionExtension(string url)
        {
            Rectangle resolution = Screen.PrimaryScreen.Bounds;
            string widthByHeight = resolution.Width + "x" + resolution.Height;
            string potentialExtension = "_" + widthByHeight + ".jpg";
            if (WebsiteExists(url + potentialExtension))
            {
                Console.WriteLine("Background for " + widthByHeight + " found.");
                return potentialExtension;
            }
            else
            {
                Console.WriteLine("No background for " + widthByHeight + " was found.");
                Console.WriteLine("Using 1920x1080 instead.");
                return "_1920x1080.jpg";
            }
        }

        private static Image DownloadBackground(string url)
        {
            Console.WriteLine("Downloading background...");
            WebRequest request = WebRequest.Create(url);
            WebResponse reponse = request.GetResponse();
            Stream stream = reponse.GetResponseStream();
            return Image.FromStream(stream);
        }

        private static string GetBackgroundImagePath()
        {
            string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "Bing Backgrounds", DateTime.Now.Year.ToString());
            Directory.CreateDirectory(directory);
            return Path.Combine(directory, DateTime.Now.ToString("M-d-yyyy") + ".bmp");
        }

        private static void SaveBackground(Image background)
        {
            Console.WriteLine("Saving background...");
            background.Save(GetBackgroundImagePath(), System.Drawing.Imaging.ImageFormat.Bmp);
        }

        private enum PicturePosition
        {
            Tile,
            Center,
            Stretch,
            Fit,
            Fill
        }

        internal sealed class NativeMethods
        {
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            internal static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
        }

        private static void SetBackground(Image background, PicturePosition style)
        {
            Console.WriteLine("Setting background...");
            using (RegistryKey key = Registry.CurrentUser.OpenSubKey(Path.Combine("Control Panel", "Desktop"), true))
            {
                switch (style)
                {
                    case PicturePosition.Tile:
                        key.SetValue("PicturePosition", "0");
                        key.SetValue("TileWallpaper", "1");
                        break;
                    case PicturePosition.Center:
                        key.SetValue("PicturePosition", "0");
                        key.SetValue("TileWallpaper", "0");
                        break;
                    case PicturePosition.Stretch:
                        key.SetValue("PicturePosition", "2");
                        key.SetValue("TileWallpaper", "0");
                        break;
                    case PicturePosition.Fit:
                        key.SetValue("PicturePosition", "6");
                        key.SetValue("TileWallpaper", "0");
                        break;
                    case PicturePosition.Fill:
                        key.SetValue("PicturePosition", "10");
                        key.SetValue("TileWallpaper", "0");
                        break;
                }
            }
            const int SetDesktopBackground = 20;
            const int UpdateIniFile = 1;
            const int SendWindowsIniChange = 2;
            NativeMethods.SystemParametersInfo(SetDesktopBackground, 0, GetBackgroundImagePath(), UpdateIniFile | SendWindowsIniChange);
        }
    }
}

答案 8 :(得分:2)

这个JavaScript将回答如何处理api&#39;通过将div的背景图像更改为当前日期图像的背景。

function PullBackground() {
    var ajaxRequest = new XMLHttpRequest(), background = ''; 
    ajaxRequest.open('POST', "http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=en-US", true);
    ajaxRequest.setRequestHeader("Connection", "close");
    ajaxRequest.send('');
    ajaxRequest.onreadystatechange = function () {
        if (ajaxRequest.readyState == 4) {
            background = ajaxRequest.responseText;
            var res = background.split("<url>"); 
            var res1 = res[1].split("</url>");
            background = res1[0];

            document.getElementById('NameOfTheDivToChange').style.backgroundImage = "url('http://bing.com" + background + "')"
            document.getElementById('NameOfTheDivToChange').style.backgroundSize = "100%";
        }
    }
}

答案 9 :(得分:2)

简单PowerShell,放入文件夹,在Windows任务计划程序中创建日常任务,脚本将图像保存在其运行文件夹中,然后在桌面背景设置中选择该文件夹作为背景。

[xml]$doc = (New-Object System.Net.WebClient).DownloadString("https://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=ru-RU")
$url = $doc.images.image.url
$url = "https://www.bing.com/" + $url -replace "_1366x768","_1920x1200"

Write-Output $url

$fileName = Split-Path $url -leaf
$output = "$PSScriptRoot\$fileName"

$start_time = Get-Date
Invoke-WebRequest -Uri $url -OutFile $output
Write-Output "Saved to: $output Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"

答案 10 :(得分:2)

让我告诉您如何使用javascript和php获取bing的每日壁纸,

尝试以下js代码:

<script>
      fetch('https://techytricks97.000webhostapp.com/')
      .then(response => response.text())
      .then(text=>{document.body.style.background="url('"+text+"')";document.body.style.backgroundSize='cover';});
</script>

此脚本将bing每天的图像设置为html文档的背景(您可以根据需要对其进行进一步修改)。

此链接-https://techytricks97.000webhostapp.com每天返回当天的必应墙纸。

fetch()https://techytricks97.000webhostapp.com获取今天的bing图像的URL,然后text=>{document.body.style.background="url('"+text+"')";document.body.style.backgroundSize='cover';}将其设置为背景。

注意:Microsoft不允许将bing的每日图像用作您网站的背景,您不能将其用作电话/台式机墙纸,或用于提及版权的其他内容。

这是http://techytricks97.000webhostapp.com上使用的php代码:

<?php
header('Access-Control-Allow-Origin: *');
ini_set('display_errors', 1);
$reg=file_get_contents('https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-IN');
$reg=json_decode($reg);
$meka=$reg->images[0]->url;
echo('http://www.bing.com'.$meka);
?>

您只能使用http://techytricks97.000webhostapp.com,也可以在服务器上设置自己的php文件。

另一个说明:我不是只使用javascript,因为浏览器的同源策略对其进行了限制,但是由于我将header('Access-Control-Allow-Origin: *');放在了自己的php文件中,因此允许PHP代码。我可以使用其他代理,但它们的访问量很高(我的网站一天之内几乎没有点击)。

如果您使用任何其他语言,则只需阅读此文件(http://techytricks97.000webhostapp.com

答案 11 :(得分:1)

我无法获得可以与John’s Background Switcher一起使用的正确RSS Feed,直到我发现这个Feedburner Feed看起来效果很好:http://feeds.feedburner.com/bingimages

答案 12 :(得分:1)

查看bing-desktop-wallpaper-changer上的Github。该脚本是用python编写的,我希望你能在那里找到答案。

#!/usr/bin/python
#-*- coding: utf-8 -*-

import os
import urllib
import urllib2
from bs4 import BeautifulSoup

# Get BingXML file which contains the URL of the Bing Photo of the day
# idx = Number days previous the present day. 0 means current day, 1 means       yesterday, etc
# n = Number of images predious the day given by idx
# mkt denotes your location. e.g. en-US means United States. Put in your  country code
BingXML_URL = "http://www.bing.com/HPImageArchive.aspx?     format=xml&idx=0&n=1&mkt=en-US"
page = urllib2.urlopen(BingXML_URL)
BingXML = BeautifulSoup(page, "lxml")

# For extracting complete URL of the image
Images = BingXML.find_all('image')
ImageURL = "https://www.bing.com" + Images[0].url.text
ImageName = Images[0].startdate.text+".jpg"

urllib.urlretrieve(ImageURL, ImageName)

查看Github项目以获取详细代码

答案 13 :(得分:1)

这是一个简单的Python脚本,只使用requestsjson来获取当天的Bing照片:

import requests
import json

BING_URI_BASE = "http://www.bing.com"
BING_WALLPAPER_PATH = "/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US"

# open the Bing HPImageArchive URI and ask for a JSON response
resp = requests.get(BING_URI_BASE + BING_WALLPAPER_PATH)

if resp.status_code == 200:
    json_response = json.loads(resp.content)
    wallpaper_path = json_response['images'][0]['url']
    filename = wallpaper_path.split('/')[-1]
    wallpaper_uri = BING_URI_BASE + wallpaper_path

    # open the actual wallpaper uri, and write the response as an image on the filesystem
    response = requests.get(wallpaper_uri)
    if resp.status_code == 200:
        with open(filename, 'wb') as f:
            f.write(response.content)
    else:
        raise ValueError("[ERROR] non-200 response from Bing server for '{}'".format(wallpaper_uri))
else: 
    raise ValueError("[ERROR] non-200 response from Bing server for '{}'".format(BING_URI_BASE + BING_WALLPAPER_PATH))

这会将TurtleTears_EN-US7942276596_1920x1080.jpg等文件写入执行脚本的同一目录。当然,可以在这里调整一大堆东西,但可以很容易地完成工作。

答案 14 :(得分:1)

我终于决定使用Python 3编写脚本,以从xml档案中获取最多图像(16)。

所以现在我可以毫不费力地存档图像。只需运行Python脚本即可。
我将图像整理到Year / Month文件夹中,如下所示:2018> 12月12日> 2018-12-06.jpg

此脚本在我的Bing Wallpapers文件夹中。 (在我的图片文件夹中)

import urllib.request as urllib
import json
from datetime import date
from dateutil import parser
import sys,os

months = "January","Febuary","March","April","May","June","July","August","September","October","November","December"

def downloadBingImages(start):
    try: data = urllib.urlopen("https://www.bing.com/hpimagearchive.aspx?format=js&idx=%i&n=8&mkt=en-NZ"%start).read()
    except: sys.exit()
    e = json.loads(data.decode())
    images = e["images"]

    for image in images:
        d = parser.parse(image["startdate"]) # parse("20181206")

        filename = str(d.date())+".jpg"                         #                  2018-12-06.jpg
        folder = "%i/%i %s/"%(d.year,d.month,months[d.month-1]) # 2018/12 December/
        file = folder+filename                                  # 2018/12 December/2018-12-06.jpg

        if not os.path.exists(folder): os.makedirs(folder)
        exists = os.path.isfile(file)

        url = "https://www.bing.com"+image["urlbase"]+"_1920x1200.jpg"
        print(("downloading","exists")[exists],filename,url)
        if not exists:
            try: urllib.urlretrieve(url,file)
            except: sys.exit()

    print()

# downloads the 16 latest bing images
downloadBingImages(-1)
downloadBingImages(7)

可选的额外代码来更新壁纸:(放在downloadBingImages(7)下面)

import ctypes,win32con

def getWallpaper():
    ubuf = ctypes.create_unicode_buffer(512)
    ctypes.windll.user32.SystemParametersInfoW(win32con.SPI_GETDESKWALLPAPER,len(ubuf),ubuf,0)
    return ubuf.value

def setWallpaper(path):
    changed = win32con.SPIF_UPDATEINIFILE | win32con.SPIF_SENDCHANGE
    ctypes.windll.user32.SystemParametersInfoW(win32con.SPI_SETDESKWALLPAPER,0,path,changed)

# update wallpaper after a week from current
wallpaper = getWallpaper()
if wallpaper.startswith(os.getcwd()): # has to be in script directory
    try: wallpaperDate = parser.parse(os.path.splitext(os.path.basename(wallpaper))[0])
    except: sys.exit() # not using an image with a parsable date

    t = date.today()
    if (t-wallpaperDate.date()).days>=7: # been a week or longer
        setWallpaper(os.path.abspath("%i/%i %s/"%(t.year,t.month,months[t.month-1])+str(t)+".jpg")) # .../2018/12 December/2018-12-14.jpg

示例输出:

exists 2018-12-15.jpg https://www.bing.com/az/hprichbg/rb/YosemiteBridge_ROW11493343707_1920x1200.jpg
exists 2018-12-14.jpg https://www.bing.com/az/hprichbg/rb/CardinalBerries_ROW13321753978_1920x1200.jpg
exists 2018-12-13.jpg https://www.bing.com/az/hprichbg/rb/ReykjavikYuleLads_ROW12406174277_1920x1200.jpg
exists 2018-12-12.jpg https://www.bing.com/az/hprichbg/rb/PoinsettiaBuds_ROW14015106672_1920x1200.jpg
exists 2018-12-11.jpg https://www.bing.com/az/hprichbg/rb/KilimanjaroMawenzi_ROW12001033920_1920x1200.jpg
exists 2018-12-10.jpg https://www.bing.com/az/hprichbg/rb/ChristmasIslandCrab_ROW12174154872_1920x1200.jpg
exists 2018-12-09.jpg https://www.bing.com/az/hprichbg/rb/JohnDaySnow_ROW10922424229_1920x1200.jpg
exists 2018-12-08.jpg https://www.bing.com/az/hprichbg/rb/BanffEvergreens_ROW13248925556_1920x1200.jpg

exists 2018-12-07.jpg https://www.bing.com/az/hprichbg/rb/TaisetsuShirakawago_ROW12053480529_1920x1200.jpg
exists 2018-12-06.jpg https://www.bing.com/az/hprichbg/rb/Huuhkajat_ROW11700922065_1920x1200.jpg
exists 2018-12-05.jpg https://www.bing.com/az/hprichbg/rb/SurfersBronteBeach_ROW9358782018_1920x1200.jpg
exists 2018-12-04.jpg https://www.bing.com/az/hprichbg/rb/SphinxObservatory_ROW9691446114_1920x1200.jpg
exists 2018-12-03.jpg https://www.bing.com/az/hprichbg/rb/HussarPoint_ROW8654856850_1920x1200.jpg
exists 2018-12-02.jpg https://www.bing.com/az/hprichbg/rb/Nuuk_ROW12381573676_1920x1200.jpg
exists 2018-12-01.jpg https://www.bing.com/az/hprichbg/rb/RedAntarctica_ROW12620598839_1920x1200.jpg
exists 2018-11-30.jpg https://www.bing.com/az/hprichbg/rb/KilchurnSky_ROW9474162800_1920x1200.jpg

P.S。上面的脚本将&mkt=en-NZ用于新西兰图像。
您可以查看其他国家/地区的市场代码here

您还可以查看自2009年以来在不同国家/地区here存档的所有图像。
(尽管仅在1366x768中)

主要P.S.将脚本添加到任务计划程序以在登录时运行。 (或每天/每周)

创建基本任务
程序/脚本:python(如果不在您的环境路径中,则为C:\ Python34 \ python.exe)
参数:“ path / to / your / script.py”
开始于:“路径/到达/您的”

更新! (2019年3月)
xml和rss格式给2019-03-10的图像提供了错误的开始日期(20190309)。
改用Json格式。 (因为它提供了准确的日期)

答案 15 :(得分:0)

OP未指定操作系统,因此这里是供Linux使用的操作系统。我从提供的here脚本中进行了修改。

基本上,它获取当天图像的url,下载图像并将其保存到固定文件~/.config/wallpaper.jpg中,并使用feh设置墙纸。同时发送通知。

#!/bin/sh

WP_FILE=$HOME/.config/wallpaper.jpg

bing="www.bing.com"

# $xmlURL is needed to get the xml data from which
# the relative URL for the Bing pic of the day is extracted
#
# The mkt parameter determines which Bing market you would like to
# obtain your images from.
# Valid values are: en-US, zh-CN, ja-JP, en-AU, en-UK, de-DE, en-NZ, en-CA or opted out.
#
# The idx parameter determines where to start from. 0 is the current day,
# 1 the previous day, etc.
xmlURL="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=en-US"

# The desired Bing picture resolution to download
# Valid options: "_1024x768" "_1280x720" "_1366x768" "_1920x1200"
desiredPicRes="_1920x1080"

# The file extension for the Bing pic
picExt=".jpg"

# Extract the relative URL of the Bing pic of the day from
# the XML data retrieved from xmlURL, form the fully qualified
# URL for the pic of the day, and store it in $picURL

# Form the URL for the desired pic resolution
desiredPicURL=$bing$(curl -s $xmlURL | grep -oP "(?<=<urlBase>)(.*?)(?=</urlBase>)")$desiredPicRes$picExt

# Form the URL for the default pic resolution
defaultPicURL=$bing$(curl -s $xmlURL | grep -oP "(?<=<url>)(.*?)(?=</url>)")

# $picName contains the filename of the Bing pic of the day

# Attempt to download the desired image resolution. If it doesn't
# exist then download the default image resolution
if wget --quiet --spider "$desiredPicURL"
then

    # Download the Bing pic of the day at desired resolution
    curl -s -o "$WP_FILE" "$desiredPicURL"
else
    # Download the Bing pic of the day at default resolution
    curl -s -o "$WP_FILE" "$defaultPicURL"
fi

if [[ -f "${WP_FILE}" ]]; then
    feh --bg-scale "$WP_FILE" && \
        notify-send -i emblem-photos "Wallpaper" "Wallpaper changed" \
        -h int:suppress-sound:1 -h int:transient:1
fi

答案 16 :(得分:0)

扑除一根衬里(需要扑,卷曲和jq),可用于放置cronjob:

BACKGROUND_META=$(curl 'https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US'); curl -o $(echo $BACKGROUND_META | jq -r '.images[0].urlbase' | sed s/.*=//).jpg "https://bing.com$(echo $BACKGROUND_META| jq -r '.images[0].url')"

答案 17 :(得分:0)

https://bingdesktop.com/gallery/feed将列出没有Bing徽标的最新Bing图片,并由bingdesktop.com维护。支持以下国家/地区:AU,CA,CN,DE,FR,JP,US,GB。

例如,https://bingdesktop.com/gallery/feed?country=jp代表日本,https://bingdesktop.com/gallery/feed?country=us代表美国。

答案 18 :(得分:0)

编辑09/27/2018: http://www.istartedsomething.com/bingimages数周回复404。它可能不再存在。 : - (

您可以使用 istartedsomething.com's Bing Image Archive 。这是一个非官方的Bing Image Archive。它使用自制端点,有助于检索图像:

GET /bingimages/getimage.php?id=<image_id>

id是一个字符串,其中包含图像发布的日期和发布图像的国家/地区。 id必须符合以下格式:YYYYMMDD-xx,其中:

  • YYYY是年份,用四位数字写成。
  • MM是月份,用两位数字写成。
  • DD是当天,用两位数字写的。
  • xx是国家/地区指标。 Bing Image Archive目前支持以下国家/地区:
    • au:澳大利亚。
    • br:巴西。
    • ca:加拿大。
    • cn:中国。
    • de:Deutschland。
    • fr:法国。
    • gb:英国。
    • jp:日本。
    • nz:新西兰。
    • uk:英国。
    • us:美利坚合众国。

如果它有某些信息,则返回一个有用的JSON对象;如果它没有任何信息,则返回false。

示例1: 重播2014年5月24日在新西兰发布的Bing日常图片

图片ID为20140524-nz,因为要求的图片已于2014年5月24日发布,并在新西兰出版,其国家/地区指标为nz

http://www.istartedsomething.com/bingimages/getimage.php?id=20140524-nz返回以下JSON:

{
    "url":"\/az\/hprichbg\/rb\/LakeMagadiFlamingos_ROW9792683076_1366x768.jpg",
    "region":"nz",
    "date":"2014-05-24",
    "copyright":"Flamingos take flight, Lake Magadi, Kenya (\u00a9 Bobby Haas\/Getty Images)(Bing New Zealand)",
    "imageurl":"http:\/\/www.istartedsomething.com\/bingimages\/cache\/LakeMagadiFlamingos_ROW9792683076_1366x768.jpg",
    "hotspots":[],
    "video":[]
}

您可以使用imageurl字段或url(Bing网址路径)字段来获取图片。

示例2: 重播1998年7月12日在法国发布的Bing日常图像

图片ID为19980712-fr,因为所需图片于1998年12月7日发布,并在法国发布,其国家/地区指标为fr

http://www.istartedsomething.com/bingimages/getimage.php?id=19980712-fr会返回false,因为法国在1998年7月12日没有Bing每日图像(Bing此时甚至不存在)。

答案 19 :(得分:0)

你可以在Linux机器上使用python和wget来做到这一点:

fileURL

它在名称daily_im.jpg下的本地目录中下载每日bing背景。您可以将所有内容放在script.py上并以编程方式启动它。

答案 20 :(得分:0)

使用@Siv中的网址,以下是更新function GetImageURL(ans) { var suffix = ans.images[0].url document.getElementById("background").style.backgroundImage = 'url("' + 'http://bing.com/' + suffix + '"' } function GetJSON() { var xmlhttp = new XMLHttpRequest() var url = "https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1" xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { var ans = JSON.parse(this.responseText); GetImageURL(ans); } }; xmlhttp.open("GET", url, true); xmlhttp.send(); } window.onload = function () { GetJSON() }

的JavaScript示例
.bgimg {
    height: 100%;
    position: relative;
    opacity: 0.95;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

这门课的css是:

{{1}}

答案 21 :(得分:0)

您可以考虑获取该网址的file_content并在文件中搜索该图片。 不确定这是最好的方式,但这是一种方式。