Google News
Easy peasy way to get the most recent news from Google Newspaper RSS
With npm do:
npm install @vorlefan/google-news @vorlefan/path xml2json
With yarn do:
yarn add @vorlefan/google-news @vorlefan/path xml2json
Documentation
I'm creating a simple website using Vercel to use as demo and documentation.
W.I.P
Highlight
- Easy way to define where to save
- Multiple Queries
- Save results in both raw (xml) and json (parsed)
Bootstrap
Shortcut to the definitions and settings to execute the crawler.
Structure
import { GoogleNews } from '@vorlefan/google-news';
const news = new GoogleNews(searchs, options);
[searchs]
The paramater searchs can be either a single string or a array of strings. In which, will be
the search for the news.
[options]
Checkout the types for this paramater in which needs to be an {Object}
saveXml?: boolean;
saveJson?: boolean;
timeout?: number | null;
route?: (route: PathRoute) => void;
routeName: string;
language?: string;
localization?: string;
- saveXml : If you don't want to keep the xml saved, then set it false.
- saveJson : If you want to save the .json, then set it true.
- timeout : If you want to set a waiting time in between each crawler, then set it in seconds
- route : If you want to define the PathRoute as create a new folder, define a new route and so on.
- routeName : Where it be gonna saved, the files.
- language : Define the language of the searching. Example: en-US to english from United State or pt-BR for brazillian
- localization : Define where it gonna be localized the search. Example: US for United State or BR for Brazil.
Return
The methods and variables that you can interact when calling the class GoogleNews, is:
import { GoogleNews } from '@vorlefan/google-news';
const news = new GoogleNews(searchs, options);
await news.run()
news.news()
news._news;
await news.items(orderBy?: 'asc' | 'desc');
news._route
Example
import { GoogleNews } from '@vorlefan/google-news';
const news = new GoogleNews(['Kingkiller Chronicles'], {
route: (route) => {
route.inject('google-news', 'main');
},
routeName: 'google-news',
language: 'en-US',
localization: 'US',
});
void (async function () {
await news.run();
console.log(news.items('desc'));
})();
Contributing
Thank you for being interested on making this package better. I encourage everyone to help improving this project with some new features, bug fixes and performance issues. Then please, if you can, help us to enchance
this package.