Last active
October 24, 2019 19:02
-
-
Save vlrmprjct/e5618bd1c871ef9698d90f5dde47b4be to your computer and use it in GitHub Desktop.
Daily Bing image via JS/JQuery using Yahoo Query API , bypass the access control origin policy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BING BING BING | |
// GET DAILY BING IMAGE VIA JS/JQUERY USING YAHOO QUERY API | |
// TO BYPASS ACCESS CONTROL ORIGIN POLICY | |
// | |
// KNOWN BING URL PARAMETERS ARE: | |
// format: js | xml | rss | |
// idx: 0 - n ( offset | 0 = current image only | 1 previous image ) | |
// n: 0 - n ( how many images ) | |
// mkt: country code for description ( doesnt mean the image switch for the next day, this is indicated by the tld ) | |
// | |
// EXAMPLE BELOW FETCH 2 IMAGES IN A JSON-OBJECT INCLUDING CURRENT AND PREVIOUS IMAGE | |
// http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=2&mkt=de-DE | |
// SEE: https://jsfiddle.net/telekommander/fqsg8oa7/ | |
// | |
// NOW GET THE IMAGE: | |
$.getJSON("https://query.yahooapis.com/v1/public/yql", { | |
q: "select * from json where url='https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=de-DE'", | |
format: "json" | |
}, | |
function (data) { | |
if (data.query.results) { | |
console.log(data.query.results.json.images.url); | |
} | |
} | |
); |
I know whats happening. But this is not the point.
The point is Yahoo has stopped the YQL Service, so the snippet/script is also stopped to work.
See: https://www.valuewalk.com/2019/01/yahoo-retires-yql-services/
You have to use an alternate service-layer.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, Please i need your help! I trying use your script to get the daily bing image but, is'n work. The browser return an message about Cross-Origin Request Blocked. You know what happening?