Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@hansaka02/news-fetcher

hansaka0234MIT1.1.4

An advanced Node.js module to fetch the latest news from Google News RSS.

news, rss, google-news, node-fetch, news-api, news-fetcher, breaking-news, latest-news, rss-parser, rss-feed, news-bot, news-aggregator, news-scraper, real-time-news, headlines, world-news, tech-news, sports-news, business-news, entertainment-news

readme

news Module

An advanced Node.js module to fetch the latest news from Google News RSS.

Installation

To install the module, run the following command:

npm install @hansaka02/news-fetcher

usage

To use this module, you can do the following:

Import module

const { getNews } = require('@hansaka02/news-fetcher');

fetching news text

(async () => {
    try {
        console.log('Fetching latest news...\n');

        const news = await getNews();

        if (news.error) {
            console.error('Error fetching news:', news.error);
            return;
        }

        // Display the news in a formatted way
        news.forEach((item, index) => {
            console.log(`${index + 1}. ${item.title}`);
            console.log(`   🔗 ${item.link}\n`);
        });

    } catch (error) {
        console.error('Unexpected error:', error.message);
    }
})();

you can input catogories format

Top Stories(dont input anything)
World
Nation
Business
Technology
Entertainment
Science
Sports
Health

how its use


/*------------you can use catogory or quary to filter news------------*/
getNews({category:'science'})
getNews({query:'sri lanka sports'})