I'm new to using jsdom and querystring. I'm trying to scrape a page for all of the soundcloud track_id
's within all of the iframe html tags. The code below logs undefined
because the first iframe is not a soundcloud player.
How do I...
- Modify the code to retrieve all of the iframe instances
Check if
http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F
or justsoundcloud
is present using jsdom/qs. (I can use an if string contains string type of js test, but I figure there is a better way using jsdom/qs).jsdom.env({ html: 'A_URL', scripts: [ 'http://code.jquery.com/jquery-1.5.min.js' ], done: function(errors, window) { var $ = window.$; var src = $('iframe').attr('src'); var aRes = qs.parse(decodeURIComponent(url.parse(src).query)).url.split('/'); var track_id = aRes[aRes.length-1]; console.log("track_id =", track_id); } });