Skip to content

Instantly share code, notes, and snippets.

@rlemon
Created January 18, 2012 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rlemon/1636429 to your computer and use it in GitHub Desktop.
Save rlemon/1636429 to your computer and use it in GitHub Desktop.
get all SE sites using the public API
function buildURL(page) {
return "http://api.stackexchange.com/2.0/sites?page=" + page + "&pagesize=100&filter=!LQukQ-uVfJGchnRIp_f0_O&callback=run";
}
function jsonp(url) {
var script_tag = document.createElement('script');
script_tag.src = url;
document.documentElement.appendChild(script_tag);
}
function run(json) {
se_site_list = se_site_list.concat(json.items);
if( json.has_more ) {
jsonp( buildURL(json.page+1) );
}
}
var se_site_list = [];
jsonp( buildURL(1) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment