-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (36 loc) · 872 Bytes
/
main.go
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
package main
import (
"fmt"
"github.com/tvacare/web-crawler/database"
"github.com/tvacare/web-crawler/util"
)
var (
// LINK with the data about bovespa papers
LINK = util.GetenvRequired("LINK")
// URLBASE for fetching paper info
URLBASE = util.GetenvRequired("URLBASE")
)
func init() {
// Create database connection
_ = database.NewDB()
}
func main() {
// Bovespa papers crawler
papers := crawler()
// Show 10 biggest market values
fmt.Printf(`
As 10 maiores empresas em capitais de mercado são:`)
for i := 0; i < 10; i++ {
database.CreatePaper(papers[i])
fmt.Printf(`
%d -
Sigla: %v
Empresa: - %v
Valor de Mercado: - $%v
Variaçao Diária: - %v
URL: - %v`, i+1, papers[i].Name, papers[i].Company, papers[i].MarketValue,
papers[i].DailyVariation, papers[i].URL)
}
fmt.Printf(`
--> Total de Resultados: %d`, len(papers))
}