Skip to content

Instantly share code, notes, and snippets.

@emirkin
Created May 18, 2012 23:02
Show Gist options
  • Save emirkin/2728019 to your computer and use it in GitHub Desktop.
Save emirkin/2728019 to your computer and use it in GitHub Desktop.
How to use Bobik in Javascript
/*
* Demonstrates how to scrape using different query types
*/
var urls = ['amazon.com', 'zynga.com', 'http://finance.google.com/', 'http://shopping.yahoo.com']
var queries = ["//th", "//img/@src", "return document.title", "return $('script').length", "#logo", ".logo"]
// Instantiate Bobik client from Bobik SDK available at http://usebobik.com/sdk.
// You're welcome to link directly to the JS file. However we make no guarantees about keeping the link unchanged.
// Thus, you should do it only when you have a quick and immediate access to where this url is used (e.g. during development)
var bobik = new Bobik("YOUR_AUTH_TOKEN");
bobik.scrape({
urls: urls,
queries: queries
}, function (scraped_data) {
if (!scraped_data) {
console.log("Data is unavailable");
return;
}
var scraped_urls = Object.keys(scraped_data);
for (var url in scraped_urls)
console.log("Results from " + url + ": " + scraped_data[scraped_urls[url]]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment