Skip to content

Instantly share code, notes, and snippets.

@TechNinjaWeb
Last active October 27, 2017 10:06
Show Gist options
  • Save TechNinjaWeb/21d3e68de6b59eecd76e4c0269615055 to your computer and use it in GitHub Desktop.
Save TechNinjaWeb/21d3e68de6b59eecd76e4c0269615055 to your computer and use it in GitHub Desktop.
Get the 500 Unit Group NOC codes from the Canadian Government site
// Requires jQuery (which is loaded on the page)
// Resource: http://www.cic.gc.ca/english/immigrate/skilled/noc.asp
// Ajax function that after successful run will return
// an array of all 500 unit group noc codes
// using the code as an index key
function GetAllNocCodes()
{
return new Promise((resolve, reject) =>
$.ajax({method: 'get', url: 'http://www.cic.gc.ca/english/immigrate/skilled/noc.asp', success: function(res){
resolve(Array.prototype.slice.call($(res).find('#noc tr')).map(el=>({ [el.cells[0].innerText]: Array.prototype.slice.call(el.cells).map(c=>c.innerText) })))
}})
)
}
// IMPLEMENTATION
GetAllNocCodes().then(
data=> console.log("Your data, sir --->", data)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment