npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-gnews

v1.0.3

Published

A simple node module that loads articles from Google News

Downloads

24

Readme

node-gnews

Build Status

A simple node module that loads articles from Google News

Overview

This is an unofficial node module that allows you to easily load articles from Google News via its RSS feed and convert them into JavaScript Object.

Strongly inspired by google-news-rss, but tweaked a bit.

Install

npm install node-gnews --save

or in case you use yarn:

yarn add node-gnews

Usage

Clone this repo and open ./samples to run.

Get headlines

Load headlines and return it as an array.

const Gnews = require('node-gnews').Gnews;
const instance = new Gnews();

// Headlines for topics
instance.headlines().then(articles => console.log(articles)); // -> display headlines in U.S.

Get headlines in topic

Load headlines in a certain topic. Visit Google News and you will see SECTIONS on the left sidebar as below.

If you click one, the address should be something like https://news.google.com/news/headlines/section/topic/WORLD?ned=us&hl=en&gl=US. In this case, WORLD would be a topic for the content and you can pass it as a first argument of headlines().

instance.headlines('WORLD').then(articles => console.log(articles)); // -> display headlines of 'World' topic.

Note that topics may not be available on every language. Please make sure that the topic is available on a language you are going to use on a browser.

Search

Search for keywords

instance.search('Nintendo').then(articles => console.log(articles)); // -> Search result

Change Region (and more)

You may pass optional parameters to change region. As a default, the library will load news in the U.S.

For example, if you change the region to Japan on news.google.com, its URL will be

https://news.google.com/news/?ned=jp&hl=ja&gl=JP

Three parameters: 'ned', 'hl' and 'gl' decide which region to load articles from so that you can use it to change the locale.

const Gnews = require('node-gnews').Gnews;
const instance = new Gnews({
  ned: 'jp',
  hl: 'ja',
  gl: 'JP'
}); // Set Japanese as a default

instance
  .headlines()
  .then(articles => console.log(articles)); // -> Japanese Headlines

instance.search('Doctor Who',{
  ned: 'uk',
  hl: 'en-GB',
  gl: 'GB'
}).then(articles => console.log(articles)); // -> Search "Doctor Who" in U.K.

All the values in the second argument will be used as parameters to load RSS so you may use it for different purposes.

Article Properties

|Property|Description|Example| |---|---|---| |title|title of the article|The Last Jedi spoiler talk: Mark Hamill discusses the secrets of Luke Skywalker's return| |link|link to the article|http://ew.com/movies/2017/12/16/the-last-jedi-spoilers-rian-johnson-mark-hamill-luke-skywalker-revelations/| |category|category of the article|More Top Stories| |pubDate|Date the article was published|Sat, 16 Dec 2017 16:00:29 GMT| |description|HTML to guide related articles|Click to see example| |publisher|Publisher of the article|EW.com| |fullCoverage|Link to the Google News Related Stories|https://news.google.com/story/dOHKnaQodeaDspMmZOqoGu4YGQ47M?hl=en&ned=us (expired)| |related|Array of related stories. Each has title, link and publisher|Click to see example| |thumbnailUrl|Thumbnail image url. Omitted when not available.|https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSzlMagnYwijdaLtdc4MWJopShsC9vRGDh-_LKP9GlJ_ofu6J8OyUFdlebTu4e1JT6mb0_YY7Lw59M|