Created
August 24, 2023 21:22
-
-
Save dragoscv/a4399a98ca749e7056e8910d1c539d48 to your computer and use it in GitHub Desktop.
Crawler minified
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)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment