Created
August 27, 2019 21:25
-
-
Save dallas-x/5d3b4ee3e20e158399a2a47095de9e2a to your computer and use it in GitHub Desktop.
extract table data. Only class name is proxy-row for the row. I need to extract data about the proxies from the table.
This file contains 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
import cheerio from 'cheerio'; | |
function parseList(response) { | |
return new Promise((resolve, reject) => { | |
const $ = cheerio.load(response.data); | |
try { | |
$('.proxy-row').each((i, el) => { | |
$(el).find('td').each((i, el) => { | |
console.log($(el).text()); | |
}); | |
}) | |
} catch (error) { | |
console.log(error); | |
reject(error); | |
} | |
}) | |
} | |
module.exports = { | |
parseList | |
} | |
// Website is https://cool-proxy.net/ | |
// Note i know there is a api call to get the json but the req is to use web scrapping to get the data. | |
//Results from my console | |
// {{proxy.ip}} | |
// {{proxy.port}} | |
// {{proxy.country_name}} | |
// {{proxy.anonymous ? 'Anonymous' : 'No'}} | |
// {{ proxy.working_average | number:0 }} | |
// {{ (proxy.response_time_average | number:2) * 1 }} | |
// {{ proxy.download_speed_average / 1000 | number:0 }} | |
// {{ proxyCtrl.unix - proxy.update_time | minSec }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment