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! | |
| 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
| <!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 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
| 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 |
NewerOlder