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
npm install --save request request-promise cheerio puppeteer |
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
npm install --save request request-promise cheerio puppeteer |
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 url = 'https://en.wikipedia.org/wiki/List_of_Presidents_of_the_United_States'; | |
rp(url) | |
.then(function(html){ | |
//success! | |
console.log(html); | |
}) | |
.catch(function(err){ | |
//handle error |
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
<!DOCTYPE html> | |
<html class="client-nojs" lang="en" dir="ltr"> | |
<head> | |
<meta charset="UTF-8"/> | |
<title>List of Presidents of the United States - Wikipedia</title> | |
... |
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! | |
console.log($('big > a', html).length); | |
console.log($('big > a', html)); | |
}) |
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
45 | |
{ '0': | |
{ type: 'tag', | |
name: 'a', | |
attribs: { href: '/wiki/George_Washington', title: 'George Washington' }, | |
children: [ [Object] ], | |
next: null, | |
prev: null, | |
parent: | |
{ type: 'tag', |
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); |
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
[ | |
'/wiki/George_Washington', | |
'/wiki/John_Adams', | |
'/wiki/Thomas_Jefferson', | |
'/wiki/James_Madison', | |
'/wiki/James_Monroe', | |
'/wiki/John_Quincy_Adams', | |
'/wiki/Andrew_Jackson', | |
... | |
] |
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 url = 'https://en.wikipedia.org/wiki/George_Washington'; | |
rp(url) | |
.then(function(html) { | |
console.log(html); | |
}) | |
.catch(function(err) { | |
//handle error | |
}); |
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
<html class="client-nojs" lang="en" dir="ltr"> | |
<head> | |
<meta charset="UTF-8"/> | |
<title>George Washington - Wikipedia</title> | |
... |
OlderNewer