se-scraper/examples/quickstart.js

33 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-06-11 18:16:59 +02:00
const se_scraper = require('./../src/node_scraper.js');
2019-01-30 23:53:09 +01:00
2019-06-11 18:16:59 +02:00
(async () => {
let browser_config = {
2019-06-29 17:00:19 +02:00
debug_level: 2,
2019-06-11 18:16:59 +02:00
output_file: 'examples/results/data.json',
2019-06-29 17:00:19 +02:00
test_evasion: true,
2019-06-11 18:16:59 +02:00
};
2019-01-30 23:53:09 +01:00
2019-06-11 18:16:59 +02:00
let scrape_job = {
search_engine: 'google',
keywords: ['news', 'se-scraper'],
num_pages: 1,
2019-06-11 22:01:27 +02:00
// add some cool google search settings
google_settings: {
gl: 'us', // The gl parameter determines the Google country to use for the query.
hl: 'en', // The hl parameter determines the Google UI language to return results.
start: 0, // Determines the results offset to use, defaults to 0.
num: 100, // Determines the number of results to show, defaults to 10. Maximum is 100.
},
2019-06-11 18:16:59 +02:00
};
2019-01-30 23:53:09 +01:00
2019-06-11 18:16:59 +02:00
var scraper = new se_scraper.ScrapeManager(browser_config);
await scraper.start();
var results = await scraper.scrape(scrape_job);
console.dir(results, {depth: null, colors: true});
await scraper.quit();
})();