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

Mah*_*sam 86 bing

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

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

Mat*_*zen 108

我认为最好的方法是通过他们的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>
Run Code Online (Sandbox Code Playgroud)

  • 仅供参考 - 您也可以使用JSON格式!http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1 (11认同)
  • 顺便说一句:分辨率是可变的,任何高达`_1920x1200` 的东西都可以工作,也就是`1920x1080` 和其他。 (2认同)
  • 当我尝试使用 ajax (jQuery) 获取数据时遇到跨域问题。有谁知道这个问题的解决方法? (2认同)
  • 好的,但是当通过 javascript `fetch` API 调用时,请求似乎被 CORS 策略阻止。如何解决这个问题? (2认同)

Siv*_*Siv 29

BING IMAGE的JSON格式

我找到了一种获取当天Bing ImageJSON格式的方法

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."
  }
}
Run Code Online (Sandbox Code Playgroud)

使用url来自images[]

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

这里的网址是 "url": "\/az\/hprichbg\/rb\/DayGecko_EN-US8730336235_1366x768.jpg"


kar*_*ior 10

Microsoft最近发布了针对Windows 7 的Bing动态主题,其中包含一个RSS Feed,其中包含Bing壁纸的链接.

还有一个Python脚本试图加载Bing网站并猜测正确的图像URL,但根据我的经验,它通常会导致图像分辨率低于RSS源提供的图像.

  • 不幸的是,主题已经停止,或正如微软所说:"这个主题已经退役".RSS仍然存在,但它不再被更新. (3认同)

Jon*_*ber 6

我迟到了,但万一有人需要PHP实现:我写了一个简单的类来处理这个过程:

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


Mik*_*Kay 6

Bash 一个衬垫(需要 bash、curl 和 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')"
Run Code Online (Sandbox Code Playgroud)


Shr*_*han 5

一台Liner PowerShell(3.0或更高版本)

irm 是的别名 Invoke-RestMethod

irm "bing.com$((irm "bing.com/HPImageArchive.aspx?format=js&mkt=en-IN&n=1").images[0].url)" -OutFile bing.jpg
Run Code Online (Sandbox Code Playgroud)

  • 辉煌!为我完美地工作:) (2认同)