-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
57 lines (31 loc) · 1.17 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const readline = require('readline-sync')
const credentials = require('./credencials.json')
const wikipedia = {}
wikipedia.wikipediaSearch = require('./wikipediaSearch.js')
const content = {}
const Algorithmia = require("algorithmia");
content.searchTerm = readline.question('Qual o termo de busca? ')
content.ROC = readline.questionInt('RESUMO[1] || COMPLETO[2] ')
async function wikipediaSearch(){
const input = {
"articleName": content.searchTerm,
"lang": "pt"
};
wikipedia.content = await Algorithmia.client(credentials.algorithmia)
wikipedia.algo = await wikipedia.content.algo("web/WikipediaParser/0.1.2")
wikipedia.pipe = await wikipedia.algo.pipe(input)
wikipedia.Response = await wikipedia.pipe.get()
//console.log(wikipedia.Response)
return wikipedia.Response
}
async function printarLogs(){
await wikipediaSearch()
if(content.ROC == 1){
console.log(wikipedia.Response.summary)
}else if(content.ROC == 2){
console.log(wikipedia.Response.content)
}else{
console.log("VALOR INVÁLIDO, TENTE NOVAMENTE!")
}
}
printarLogs()