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/George_Washington'; | |
rp(url) | |
.then(function(html) { | |
console.log($('.firstHeading', html).text()); | |
console.log($('.bday', html).text()); | |
}) | |
.catch(function(err) { |
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
George Washington | |
1732-02-22 |
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 potusParse = function(url) { | |
return rp(url) | |
.then(function(html) { | |
return { | |
name: $('.firstHeading', html).text(), | |
birthday: $('.bday', html).text(), | |
}; |
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 potusParse = require('./potusParse'); | |
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++) { |
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
[ | |
{ name: 'George Washington', birthday: '1732-02-22' }, | |
{ name: 'John Adams', birthday: '1735-10-30' }, | |
{ name: 'Thomas Jefferson', birthday: '1743-04-13' }, | |
{ name: 'James Madison', birthday: '1751-03-16' }, | |
{ name: 'James Monroe', birthday: '1758-04-28' }, | |
{ name: 'John Quincy Adams', birthday: '1767-07-11' }, | |
{ name: 'Andrew Jackson', birthday: '1767-03-15' }, | |
{ name: 'Martin Van Buren', birthday: '1782-12-05' }, | |
{ name: 'William Henry Harrison', birthday: '1773-02-09' }, |
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://www.reddit.com'; | |
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 | |
lang="en"><head><title>reddit: the front page of the | |
internet</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 puppeteer = require('puppeteer'); | |
const url = 'https://www.reddit.com'; | |
puppeteer | |
.launch() | |
.then(function(browser) { | |
return browser.newPage(); | |
}) | |
.then(function(page) { | |
return page.goto(url).then(function() { |
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 lang="en"><head><link | |
href="//c.amazon-adsystem.com/aax2/apstag.js" rel="preload" | |
as="script"> | |
... |
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 puppeteer = require('puppeteer'); | |
const $ = require('cheerio'); | |
const url = 'https://www.reddit.com'; | |
puppeteer | |
.launch() | |
.then(function(browser) { | |
return browser.newPage(); | |
}) | |
.then(function(page) { |