Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const cheerio = require('cheerio');
- const google = require('google');
- const request = require('superagent');
- const util = require('util');
- const misconfiguredCORS = require('./plugins/misconfiguredCORS');
- google.resultsPerPage = 100;
- const g = util.promisify(google);
- async function fetchURLsFromGoogle(q) {
- const { links } = await g(q);
- return links
- .filter(link => link.link)
- .map(link => link.link);
- }
- function* createGenerator(urls, plugin, ...args) {
- let currIndex = 0;
- while(true) {
- if(currIndex >= urls.length)
- return { done: true };
- yield plugin(urls[currIndex++], ...args);
- }
- }
- async function main(q) {
- const urls = await fetchURLsFromGoogle(q);
- const headers = await createGenerator(urls, misconfiguredCORS, 'lol.com');
- const results = await Promise.all(headers);
- return results.filter(result=>result);
- }
- main(process.argv[2])
- .then(results=>console.log(results))
- .then(() => process.exit()) // Required otherwise shit hangs
- .catch(err => console.error(err));
Add Comment
Please, Sign In to add comment