bing

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


Is there some way I could get the Bing background image programmatically?

Bing's API doesn't seem to provide such functionality, perhaps there's another way?


Solution

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

    They call this URL and extract the 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 can obviously be changed to a different region than ´en-US´, but can also be opted out of entirely if you don't care about a specific region.

    Note that the _1366x768.jpg suffix that is added to the image names appears to be modifiable into different resolutions (like _1920x1080.jpg for full HD and possibly others).

    Here's a dump of the data 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'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>