UNPKG

bquery

Version:

bquery is a useful node module to fetch web page, which use css selector to fetch and structure this html page content.

37 lines (29 loc) 1.08 kB
--- category: overview heading: 'Try it out!' --- Below is an ace editor where you can try writing a query yourself. The query below tells noodle to go to the google search result for JavaScript and expect a html file. Then using the selector pick out all of the result anchors. Finally the query says to extract the text for each of those anchor elements. Press run below to see the output: var query = { url: 'http://google.com/search?q=javascript', type: 'html', selector: 'h3.r a', extract: 'text' }, request; request = 'http://example.noodlejs.com/?q=' + encodeURIComponent(JSON.stringify(query)) + '&callback=?'; jQuery.getJSON(request, function (data) { console.log(data); demoElement.innerHTML = '<pre>' + JSON.stringify(data, null, 4) + '</pre>'; }); Noodle queries don't just support html but also json, feeds and plain xml. They can be a lot more powerful too. [Find out all noodle can do.](http://noodlejs.com/reference)