Skip to content

Instantly share code, notes, and snippets.

@DanNi0130
Created July 19, 2018 01:26
Show Gist options
  • Save DanNi0130/6cd2e4cc62426c7d8f74d7552b3509b2 to your computer and use it in GitHub Desktop.
Save DanNi0130/6cd2e4cc62426c7d8f74d7552b3509b2 to your computer and use it in GitHub Desktop.
const rp = require('request-promise');
const $ = require('cheerio');
const url = 'https://en.wikipedia.org/wiki/List_of_Presidents_of_the_United_States';
rp(url)
.then(function(html){
//success!
const wikiUrls = [];
for (let i = 0; i < 45; i++) {
wikiUrls.push($('big > a', html)[i].attribs.href);
}
console.log(wikiUrls);
})
.catch(function(err){
//handle error
});
}
@swalehakhan94
Copy link

wikiUrls.push($(‘big > a’, html)[i].attribs.href);
What is attribs in this line? I am trying to scrap a table data, can you please suggest what is the syntax to scrap the table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment