Skip to content

Instantly share code, notes, and snippets.

@malles
Created August 17, 2014 13:26
Show Gist options
  • Save malles/f2275d6c29b1313f29ee to your computer and use it in GitHub Desktop.
Save malles/f2275d6c29b1313f29ee to your computer and use it in GitHub Desktop.
scrape automerken
(function ($) {
var make = $('select#selectMake'), i = 0,
merken = make.children().map(function(){
return {val:$(this).attr('value'),text:$(this).text()}
}).get();
$.modellenLijst = {};
$.each(merken,function(){
var merk = this;
if (merk.val) {
$.ajax({
type: "GET",
url: '/home/models.html?makeId=' + merk.val + '&lang=de',
data: {}
})
.done(function (data) {
console.log(data);
var modellen = $('<div></div>').append(data).find('option').map(function () {
return $(this).text().trim()
}).get();
console.log(merk.text, modellen.length);
$.modellenLijst[merk.text.trim()] = modellen
})
}
i++;
});
})(jQuery);
jQuery('body').text(JSON.stringify(jQuery.modellenLijst));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment