Created
February 5, 2023 13:59
-
-
Save ravindu01manoj/485d2547e6b15c458da9b3545a2dffdf to your computer and use it in GitHub Desktop.
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
//Copyrigth - Ravindu Manoj (https://github.com/ravindu01manoj/) | |
var axios = require('axios') | |
var cheerio = require('cheerio') | |
async function news() { | |
var old = []; | |
var Func = async ()=>{ | |
var data = await axios.get('https://nethnews.lk') | |
var l = cheerio.load(data.data) | |
var news_url = l('div.top_breaking_news_content > div.td-read-more > a').attr('href') | |
if(old.includes(news_url.split('article/')[1])) return; | |
old.push(news_url.split('article/')[1]) | |
var result = { | |
news_url, | |
title: l('div.top_breaking_news_title > h3').text().trim(), | |
date: l('div.top_breaking_news_title > div. publish_date').text().trim(), | |
short_desc : l('div.top_breaking_news_content > div.top_breaking_news_discription').text().trim(), | |
desc: cheerio.load((await axios.get(news_url)).data)('div.content_left > div > div > div > div.td-post-content').text().trim(), | |
views : l('div.top_breaking_news_content > div.td-post-views').text().trim(), | |
img: l('div.top_breaking_news_image > img').attr('src') | |
} | |
// console.log(result) | |
// do something With Results | |
} | |
setIntraval(Func,10 * 1000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment