Is there any way to get a Bing photo of the day?

Is there any way to get the Bing background image programmatically?

The Bing API does not seem to provide such functionality, maybe there is another way?

+83
bing
May 17 '12 at 16:44
source share
20 answers

I think the best way is how they do it themselves through their AJAX calls.

They invoke this URL and retrieve information through XML deserialization.

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

The mkt attribute mkt obviously be changed to a different region than to 'en-US', but can also be completely excluded if you do not need a specific region.

Please note that the suffix _1366x768.jpg added to image names can be changed in different resolutions (for example, _1920x1080.jpg for full HD and, possibly, for others).

Here is the data dump as of 9/28/2013, in XML format.

 <?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 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> 
+103
Aug 07 '13 at 6:32
source share

JSON BING IMAGE FORMAT

I found a way to get the JSON Bing Image format of the day

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

Note

n= No images u want (u can use Integers )
mkt= Your location (example: ru-US )




Here is the JSON output looks like
  { "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 mountaineer 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." } } 



use url from images[]

and add it to 'http://bing.com'

here url is "url": "\/az\/hprichbg\/rb\/DayGecko_EN-US8730336235_1366x768.jpg"

+28
Apr 18 '14 at 8:33
source share

Microsoft recently published the Bing Dynamic Theme for Windows 7, which contains an RSS feed with links to Bing wallpapers .

There is also a Python script that tries to download the Bing website and guess the correct image URL, but in my experience, it usually results in lower resolution than the images offered by the RSS feed.

+10
Oct 24
source share

I'm late to the party, but if someone needs a PHP implementation: I wrote a simple class that processes the procedure:

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

+6
Nov 22 '15 at 21:49
source share

One PowerShell Insert (3.0 or later)

irm is an alias for Invoke-RestMethod

 irm "bing.com$((irm "bing.com/HPImageArchive.aspx?format=js&mkt=en-IN&n=1").images[0].url)" -OutFile bing.jpg 
+5
Feb 17 '17 at 9:47
source share

I also like Bing images, but their application is too bloated to load images. After analyzing the connection with fiddler, I wrote this code. The 1920x1200 comes with the Bing logo, but the low resolution doesn't.

You may have windows showing random images from the images folder that you installed, since you upload them daily, this will show you more random images. If you save "imageDir", you need to change the permissions in this folder or it will work, I did not worry about trap errors. Finally, do not comment on the lines if you want to set the wallpaper for today, or you can create a task to launch the program, say, a minute after entering the system.

 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(); } } } } 
+4
Jun 12 '14 at 13:15
source share

I saw that many people are also asking for a new RSS link, just change the format parameter in the url to "rss".

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

+3
Aug 18 '14 at 10:01
source share

This JavaScript will answer “what to do with api” by changing the background image of the div to the background of the current bing image.

 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%"; } } } 
+2
Aug 01 '14 at 12:17
source share

If someone is looking for possible implementations, I wrote a small C # command-line program to download, save and set the background as Bing Image of the Day. Feel free to modify it to suit your personal needs. 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("Md-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); } } } 
+2
Jun 12 '15 at 10:22
source share

Simple PowerShell, place it in a folder, create a daily task in the Windows Task Scheduler, the script will save the images in its launch folder, then select this folder as the background in the desktop wallpaper settings.

 [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)" 
+2
May 08 '18 at 1:12
source share

Let me tell you how to get daily wallpapers using javascript and php,

Try this JS code:

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

This script sets the daily image of the day as the background of your HTML document (you can further modify it to suit your use).

This link- https://techytricks97.000webhostapp.com returns plentiful wallpapers of the day, every day.

fetch() gets the URL of today's bing image from https://techytricks97.000webhostapp.com and text=>{document.body.style.background="url('"+text+"')";document.body.style.backgroundSize='cover';} sets it as the background.

Note. Microsoft does not allow you to use daily bing images as the background of your site, you can use them as wallpaper for your phone / desktop or for other purposes with a mention of copyright.

Here is the php code that is used at http://techytricks97.000webhostapp.com :

 <?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); ?> 

You can only use http://techytricks97.000webhostapp.com or configure your own php file on your server.

One more note: I did not use only javascript, because the browser-origin-policy restricts it, but fetching from my php file is allowed, since I set header('Access-Control-Allow-Origin: *'); in my php code. I could use other proxies, but they have high traffic (my site receives almost no clicks per day).

If you use any other language, you just need to read this file ( http://techytricks97.000webhostapp.com )

+2
Jun 22 '18 at 8:19
source share

I'm having trouble getting the right RSS feed that I could use with Johns Background Switcher until I found this feedburner feed, which seems to work quite well: http://feeds.feedburner.com/bingimages

+1
Apr 12 '16 at 16:18
source share

Check out bing-desktop-wallpaper-changer on Github . The script is written in python, and I hope you find your answer there.

 #!/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. eg 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) 

Take a look at the Github project for detailed code.

+1
Aug 07 '16 at 9:43
source share

Here is a simple Python script to get a Bing photo of the day using only requests and json :

 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)) 

This will allow you to write a file such as TurtleTears_EN-US7942276596_1920x1080.jpg to the same directory where the script is running. Of course, here you can configure a whole bunch of things, but to cope with this task is quite easy.

+1
May 24 '18 at 4:23
source share

I just finally decided to write a script in Python 3 to get the largest number of images (16) from the xml archive.

So now I can archive images effortlessly. Just run the Python script.
I arrange the images in the Year / Month folders as follows: 2018> December 12> 2018 -1 2-06.jpg

This script is in my Bing Wallpapers folder. (which is in my image folder)

 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) 

Additional additional code for updating the wallpaper: (put BingImages (7) under the download)

 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 

output example:

 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 

PS The above script uses &mkt=en-NZ for New Zealand images.
You can check the market code for other countries here .

You can also see all the images archived since 2009 for different countries, here .
(only at 1366x768 though)

Major PS add a script to the task scheduler to run when you log in. (or daily / weekly)

Create a primary task
Program / script: python (or C: \ Python34 \ python.exe if it is not in the env path)
Arguments: "path / to / your / script.py"
start with: "path / to / yours"

UPDATE! (March 2019)
An incorrect start date (20190309) in xml and rss format was specified for the image 2019-03 -1 0.
Instead, the Json format is used. (as it gives the exact date)

+1
Dec 14 '18 at 13:27
source share

You might want to get the component_file of this URL and search for a file for the image. Not sure what the best way, but it is a way.

0
May 17 '12 at
source share

Using the URL from @Siv, here is a JavaScript example updating <div class="bgimg" id="background">

 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() } 

Css for this class:

 .bgimg { height: 100%; position: relative; opacity: 0.95; background-position: center; background-repeat: no-repeat; background-size: cover; } 
0
Aug 2 '17 at 23:29
source share

You can do this using python and wget on a Linux machine:

 import os # import the os package os.system("wget -O index.html http://www.bing.com") # download the bing index str1 = open('index.html', 'r').read() # extract the file path using split str2=str1.split("g_img={url: \"")[1] str3=str2.split(".jpg")[0] os.system("wget -O daily_im.jpg http://www.bing.com" + str3 + ".jpg") # donwload the daily image 

It loads the daily message background into a local directory named daily_im.jpg. You can put everything in script.py and run it programmatically.

0
Jan 02 '18 at 15:34
source share

EDIT 27/27/2018: http://www.istartedsomething.com/bingimages responds 404 in a few weeks. Perhaps it no longer exists. :-(

You can use istartedsomething.com Bing Image Archive . This is an unofficial Bing image archive. It uses a home endpoint that is useful for capturing images:

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

id is a string containing the date the image was published and the country in which it was published. id must conform to the following format: YYYYMMDD-xx , where:

  • YYYY is a four-year year.
  • MM is a month written in two digits.
  • DD is a day written in two digits.
  • xx is an indicator of the country. Currently, Bing Image Archive supports the following countries:
    • au : Australia.
    • br : Brazil.
    • ca : Canada.
    • cn : China.
    • de : Deutschland.
    • fr .
    • gb : United Kingdom.
    • jp : Japan.
    • nz : New Zealand.
    • uk : UK.
    • us : United States of America.

It returns a useful JSON object if it has any information, or false if it has nothing.

Example 1. Getting a daily image of Bing, which was published May 24, 2014 in New Zealand.

- 20140524-nz 24.05.2014 , 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 URL path), .

2. Bing, 12 1998 .

- 19980712-fr 12/12/1998 , fr .

http://www.istartedsomething.com/bingimages/getimage.php?id=19980712-fr false Bing Daily Image 07/12/1998 ( Bing ).

0
29 '18 14:54
source share

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 .

0
24 '19 15:10
source share



All Articles