JSFiddle - React, Tailwind, and code Playground
by novikov433
JavaScript
// pl-scraper.js
var axios = require('axios');
var cheerio = require('cheerio');
var url = 'https://www.benzinga.com/stock/aapl/';
axios(url)
.then(response => {
var html = response.data;
var $ = cheerio.load(html)
var statsTable = $('#stories-headlines > ul > li');
var topPremierLeagueScorers = [];
statsTable.each(function () {
var author = $(this).find('.author').text();
var date = $(this).find('.date').text();
var url = $(this).find('a').text();
topPremierLeagueScorers.push({
author,
date,
url
});
});
console.log(topPremierLeagueScorers);
})
.catch(console.error);
var a = topPremierLeagueScorers;
const translate = require('@vitalets/google-translate-api');
translate(a, {to: 'ru'}).then(res => {
console.log(res.text);
//=> I speak English
console.log(res.from.language.iso);
//=> nl
}).catch(err => {
console.error(err);
});