Read ME
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
fetch('https://www.libertatea.ro/').then(response=>response.text()).then(data=>{var parser=new DOMParser(),doc=parser.parseFromString(data,'text/html'),articles=[],articleElements=doc.querySelector('.opinions-and-news ul').querySelectorAll('li');for(var i=1;i<Math.min(articleElements.length,4);i++){var title=articleElements[i].querySelector('h3.article-title').textContent,link=articleElements[i].querySelector('a').getAttribute('href');articles.push({title:title,link:link})}console.log(JSON.stringify(articles,null,2))}).catch(error=>console.Error(error)); |
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
fetch('https://www.libertatea.ro/') | |
.then(response => response.text()) | |
.then(data => { | |
var parser = new DOMParser(); | |
var doc = parser.parseFromString(data, 'text/html'); | |
// console.log(doc); | |
var articles = []; | |
var articleElements = doc.querySelector('.opinions-and-news ul').querySelectorAll('li'); | |
console.log(articleElements) |
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
const puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch( | |
// { | |
// headless: false, | |
// defaultViewport: null, | |
// args: ['--start-maximized'] | |
// } | |
); |