-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
74 lines (63 loc) · 1.73 KB
/
main.go
File metadata and controls
74 lines (63 loc) · 1.73 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"flag"
"os"
"github.com/joho/godotenv"
log "github.com/sirupsen/logrus"
)
func init() {
log.SetFormatter(
&log.TextFormatter{
DisableColors: false,
ForceColors: true,
FullTimestamp: true,
},
)
}
func main() {
input := flag.String("input", "./osint.json", "Provide a path to input file with links to articles")
flag.Parse()
err := godotenv.Load()
if err != nil {
log.Errorf("Failed to load environment variables %v", err)
}
if _, err := os.Stat(*input); os.IsNotExist(err) {
articles, err := FetchArticles(*apiKey, *query)
if err != nil {
log.Errorf("Error fetching articles: %v\n", err)
return
}
if err := SaveArticles("osint.json", articles); err != nil {
log.Errorf("Error saving articles: %v\n", err)
return
}
log.Println("Data saved to osint.json")
}
articles, err := LoadArticles(*input)
if err != nil {
log.Errorf("Error loading articles: %v\n", err)
return
}
processArticles, err := processArticles(articles, *onlyScrape)
if err != nil {
log.Errorf("Error processing articles: %v", err)
return
}
if *onlyScrape {
if err := saveScrapedContent(*outputFile, processArticles); err != nil {
log.Errorf("Error saving scraped content: %v", err)
return
}
log.Printf("Scraped content saved to %s\n", *outputFile)
} else {
if err := saveProcessedArticles("labeled_articles.json", processArticles); err != nil {
log.Errorf("Error saving processed articles: %v", err)
return
}
log.Printf("Analysis complete. Results saved to labeled_articles.json")
if err := generateSummaryReport("summary.md", processArticles); err != nil {
log.Errorf("Error generating summary report %v", err)
}
log.Println("Summary report saved to summary.md")
}
}