Skip to content

Instantly share code, notes, and snippets.

@mhkeller
Created February 6, 2019 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhkeller/58dc737a1f69f406b4e8921bb4e6a301 to your computer and use it in GitHub Desktop.
Save mhkeller/58dc737a1f69f406b4e8921bb4e6a301 to your computer and use it in GitHub Desktop.
promisified wget
async function downloadPage (matches) {
for (let match of matches) {
const requestUrl = `tktk`;
const html = await wget(requestUrl);
}
}
async function wget (requestUrl) {
return new Promise((resolve, reject) => {
const cmd = `wget -q -O - '${requestUrl}'`;
child.exec(cmd, (err, stdout, stderr) => {
return err ? reject(err) : resolve(stdout);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment