1.1.2 • Published 1 year ago

hiru-news v1.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

This is Unofficial API to hiru news

This script is a Node.js module that scrapes the news website "https://www.hirunews.lk" for the latest news articles and returns the information in JSON format. It uses the libraries axios, bodyParser, cheerio, cors, express, moment, openai, and request to make the necessary HTTP requests, parse the HTML response, and format the output.

The script first sends an HTTP request to the website and then selects the third article on the page. It extracts the article's title, summary, image link, content, and publication time, as well as generates a unique ID for the article. The article's content is further processed to remove unnecessary HTML tags and formatting before being returned. The resulting JSON object includes all the extracted information and can be used by other applications to display the latest news articles from Hiru News.

Installation

npm install hiru-news

fo use

import hirunews from 'hiru-news';

async function search () {
  try {
    const keycode = "your keycode";
    const articles = await hirunews(keycode);
    console.log(articles[0])
 } catch (error) {
    console.error(error);
  }
}

search();

output

{
  author: 'Hiru news - https://www.hirunews.lk',
  ID: '330264',
  time: '2023-03-18 14:22:48',
  title: 'දියර බිත්තර බද්ද 1,100කින් බහී',
  link: 'https://www.hirunews.lk/330264/දියර-බිත්තර-බද්ද-1100කින්-බහී',
  imglink: 'https://cdn.hirunews.lk/Data/News_Images/202303/1679129469_5032786_hirunews.jpg',
  content: 'බිත්තර ආනයනය සඳහා අවශ්‍ය මූලික පියවර සියල්ල විෂයභාර අමාත්‍යවරයා ලෙස ගෙන තිබුණ ද ඇතැම් පුද්ගලයින්ගg',
ේ ක්‍රියාකලාප හේතුවෙන් එය ප්‍රමාද වූ බව වෙළඳ අමාත්‍ය නලින් ප්‍රනාන්දු පවසනවා.\n' +
    'අමාත්‍යවරයා වැඩිදුරටත් සඳහන් කළේ, දියර බිත්තර ආනයනය සඳහා බදු සහනයක්ද ලබා දී ඇති බවයි.\n' +
    'ඒ අනුව දියර බිත්තර ආනයනය කිරීමේ දී පනවා තිබූ රුපියල් 1300ක තිබූ බද්ද රුපියල් 200ක් දක්වා ඊයේ (17) මධ්‍යම
 රාත්‍රියේ සිට ක්‍රියාත්මක වන පරිදි අඩු කළ බව අමාත්‍යවරයා පැවසුවා.\n' +
    'මේ අතර එළවළු , ලොකු ළුෑණු අර්තාපල් ඇතුළු දුව්‍යවල තොග මිලෙහි ද ශීඝ්‍ර අඩුවීමක් දක්නට ලැබුණ ද එහි වාසිය ප
ාරිභෝගික ජනතාව වෙත නොලැබෙන බවටයි ආපනශාලා හිමියන්ගේ සංගමයේ සභාපති අසේල සම්පත් චෝදනා කරන්නේ.'
}
For example you can take the vars here as needed
import hirunews from 'hiru-news';

async function search () {
  try {
    const keycode = "your keycode";
    const articles = await hirunews(keycode);

    articles.forEach(article => {
      console.log(`Author : `+article.author)
      console.log(`ID : `+article.ID);
      console.log(`Time : `+article.time);
      console.log(`Title : `+article.title);
      console.log(`Link : ` +article.link);
      console.log(`Image Link : ` +article.imglink);
      console.log(`Content : `+article.content);

    });
  } catch (error) {
    console.error(error);
  }
}

search();
output
Author : Hiru news - https://www.hirunews.lk
ID : 330267
Time : 2023-03-18 14:44:24
Title : අවමගුලෙන් කෙලවර වූ මගුල (වීඩියෝ)
Link : https://www.hirunews.lk/330267/අවමගුලෙන්-කෙලවර-වූ-මගුල-වීඩියෝ
Image Link : https://cdn.hirunews.lk/Data/News_Images/202303/1679130283_612198_hirunews.jpg
Content : අඟුරුවාතොට ප්‍රද්ශයේ දී දෙපිරිසක් අතර ඇති වූ ගැටුමකින් පුද්ගලයෙකු මියගොස් තවත් 5 දෙනෙකු තුවාල ලබා ර
ෝහල් ගත කර තිබෙනවා.
පොලිසිය පැවසූවේ මංගල උත්සවයක දී ඇති වූ බහින්බස් වීමක් දුරදිග යෑමෙන් මෙම ගැටුම හටගෙන ඇති බවයි.
ඊයේ අලුයම 3ට පමණ අගුරුවාතොට බටගොඩ හන්දියේ දී දෙපිරිසක් අතර මෙම ගැටුම හටගෙන තිබෙනවා.

About KEY CODE

The reason for putting a key code is to prevent possible misdeeds by using this api. If you want to get the key code, please send a gmail to our gmail account apokryfistikiairesi@gmail.com and enter your phone number.

Disclaimer

If there is a problem in this regard, please send an email to our email address apokryfistikiairesi@gmail.comand we will be flexible according to your needs.

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago