Created
July 19, 2018 01:26
-
-
Save DanNi0130/6cd2e4cc62426c7d8f74d7552b3509b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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