-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
19,782 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.txt] | ||
trim_trailing_whitespace = false | ||
|
||
[*.json] | ||
insert_final_newline = false |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"env": { "es6": true, "node": true }, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 2018, | ||
"sourceType": "module", | ||
"project": "./tsconfig.json" | ||
}, | ||
"plugins": ["@typescript-eslint"], | ||
"rules": { | ||
"semi": "off", | ||
"no-console": "error", | ||
"camelcase": "off", | ||
"@typescript-eslint/camelcase": "off", | ||
"@typescript-eslint/semi": ["off"], | ||
"@typescript-eslint/ignoreRestArgs": true, | ||
"@typescript-eslint/fixToUnknown": true | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
|
||
# builds | ||
build | ||
dist | ||
.rpt2_cache | ||
coverage | ||
|
||
# misc | ||
.DS_Store | ||
.env | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.next | ||
out | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
coverage | ||
coverage/**/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
12.13.0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
src/ | ||
node_modules | ||
docs/ | ||
examples/ | ||
test/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
12.16.1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
trailingComma: 'es5', | ||
tabWidth: 4, | ||
semi: true, | ||
singleQuote: true, | ||
overrides: [ | ||
{ | ||
files: '*.test.js', | ||
options: { | ||
semi: true, | ||
}, | ||
}, | ||
], | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"deno.enable": false | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,131 @@ | ||
# google-news | ||
# Google News | ||
|
||
Easy peasy way to get the most recent news from Google Newspaper RSS | ||
|
||
[](https://bundlephobia.com/result?p=@vorlefan/google-news)] | ||
|
||
With [npm](https://npmjs.org) do: | ||
|
||
``` | ||
npm install @vorlefan/google-news | ||
``` | ||
|
||
With [yarn](https://yarnpkg.com/en/) do: | ||
|
||
``` | ||
yarn add @vorlefan/google-news | ||
``` | ||
|
||
<hr> | ||
|
||
## Documentation | ||
|
||
I'm creating a simple website using Vercel to use as demo and documentation. | ||
**W.I.P** | ||
|
||
<hr> | ||
|
||
## Highlight | ||
|
||
- Easy way to define where to save | ||
- Multiple Queries | ||
- Save results in both raw (xml) and json (parsed) | ||
|
||
<hr> | ||
|
||
## Bootstrap | ||
|
||
Shortcut to the definitions and settings to execute the crawler. | ||
|
||
### Structure | ||
|
||
```ts | ||
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}** | ||
|
||
```ts | ||
saveXml?: boolean; // default is true | ||
saveJson?: boolean; // default is true | ||
timeout?: number | null; // default is null | ||
route?: (route: PathRoute) => void; // if you want to setup the PathRoute, then define a function | ||
routeName: string; // default is 'root' | ||
language?: string; // language, default is en-US | ||
localization?: string; // geo-localization, default is US | ||
``` | ||
|
||
- _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: | ||
|
||
```ts | ||
import { GoogleNews } from '@vorlefan/google-news'; | ||
|
||
const news = new GoogleNews(searchs, options); | ||
|
||
// Execute the crawler | ||
await news.run() | ||
|
||
// return an array of the result | ||
news.news() | ||
news._news; | ||
|
||
// return an array of array containg the item of each news (the items are the result of the news itself, containg things like title, link and description) | ||
// You can define the sort if you want to. | ||
await news.items(orderBy?: 'asc' | 'desc'); | ||
|
||
// Route from @vorlefan/path | ||
news._route | ||
|
||
``` | ||
|
||
<hr> | ||
|
||
## Example | ||
|
||
```ts | ||
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', | ||
}); | ||
|
||
// Run | ||
|
||
void (async function () { | ||
await news.run(); | ||
console.log(news.items('desc')); | ||
})(); | ||
``` | ||
|
||
<hr> | ||
|
||
## 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. | ||
|
||
<hr> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"files": [ | ||
{ | ||
"path": "./dist/*.js", | ||
"maxSize": "40 kb" | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# 0.3.0 | ||
|
||
- Initial release | ||
- #method Function to save the result in both .xml and .json | ||
- #method Multiple Crawler |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
collectCoverage: true, | ||
collectCoverageFrom: ['src/**/*.ts', 'src/**/*.js'], | ||
coverageThreshold: { | ||
global: { | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
statements: 100, | ||
}, | ||
}, | ||
testEnvironment: 'node', | ||
preset: 'ts-jest', | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"watch": ["src", "types", "@types"], | ||
"ext": "ts", | ||
"exec": "yarn watch && npm link" | ||
} |
Oops, something went wrong.