Basti1110 commited on
Commit
5e5cf2c
·
verified ·
1 Parent(s): 48ad1a0

Upload render_report.py

Browse files
Files changed (1) hide show
  1. render_report.py +128 -0
render_report.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import json
3
+ import matplotlib.pyplot as plt
4
+ import networkx as nx
5
+
6
+ # Load the OSINT JSON data
7
+ with open("data.json", "r", encoding="utf-8") as f:
8
+ data = json.load(f)
9
+
10
+ # Generate sentiment pie chart
11
+ labels = list(data["sentiment_overview"].keys())
12
+ sizes = list(data["sentiment_overview"].values())
13
+ colors = ['#4CAF50', '#FFC107', '#F44336']
14
+ fig, ax = plt.subplots()
15
+ ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140, colors=colors)
16
+ ax.axis('equal')
17
+ plt.title('Sentiment Overview')
18
+ sentiment_chart = "/mnt/data/sentiment_pie_chart.png"
19
+ plt.savefig(sentiment_chart, bbox_inches='tight')
20
+ plt.close()
21
+
22
+ # Generate network graph
23
+ G = nx.Graph()
24
+ for cluster in data["network_analysis"]["clusters"]:
25
+ nodes = cluster["nodes"]
26
+ for i in range(len(nodes)):
27
+ G.add_node(nodes[i])
28
+ for j in range(i + 1, len(nodes)):
29
+ G.add_edge(nodes[i], nodes[j])
30
+
31
+ plt.figure(figsize=(8, 6))
32
+ pos = nx.spring_layout(G, seed=42)
33
+ node_colors = ['lightblue' if 'Trump' in node else 'salmon' for node in G.nodes()]
34
+ nx.draw(G, pos, with_labels=True, node_color=node_colors, edge_color='gray', node_size=1200, font_size=8)
35
+ plt.title("Network Influence Graph")
36
+ network_chart = "/mnt/data/network_graph.png"
37
+ plt.savefig(network_chart, bbox_inches='tight')
38
+ plt.close()
39
+
40
+ # Generate HTML report
41
+ html_content = f"""
42
+ <!DOCTYPE html>
43
+ <html lang="en">
44
+ <head>
45
+ <meta charset="UTF-8">
46
+ <title>OSINT Intelligence Report</title>
47
+ <style>
48
+ body {{
49
+ font-family: Arial, sans-serif;
50
+ margin: 40px;
51
+ background-color: #f9f9f9;
52
+ }}
53
+ h1 {{
54
+ color: #2c3e50;
55
+ text-align: center;
56
+ }}
57
+ h2 {{
58
+ color: #34495e;
59
+ border-bottom: 2px solid #ccc;
60
+ padding-bottom: 5px;
61
+ }}
62
+ .section {{
63
+ margin-bottom: 30px;
64
+ }}
65
+ .image {{
66
+ text-align: center;
67
+ margin: 20px 0;
68
+ }}
69
+ </style>
70
+ </head>
71
+ <body>
72
+ <h1>OSINT Intelligence Report</h1>
73
+
74
+ <div class="section">
75
+ <h2>Summary</h2>
76
+ <p>{data["summary"]}</p>
77
+ </div>
78
+
79
+ <div class="section">
80
+ <h2>Top Topics</h2>
81
+ <p>{', '.join(data["top_topics"])}</p>
82
+ </div>
83
+
84
+ <div class="section">
85
+ <h2>Notable Users</h2>
86
+ {''.join([f"<p><strong>{u['username']} ({u['type']}):</strong> {u['activity_summary']}</p>" for u in data["notable_users"]])}
87
+ </div>
88
+
89
+ <div class="section">
90
+ <h2>Network Analysis</h2>
91
+ {''.join([f"<p><strong>{c['label']}:</strong> {c['summary']}</p>" for c in data["network_analysis"]["clusters"]])}
92
+ </div>
93
+
94
+ <div class="section">
95
+ <h2>Sentiment Overview</h2>
96
+ <p>Positive: {data['sentiment_overview']['positive']}%</p>
97
+ <p>Neutral: {data['sentiment_overview']['neutral']}%</p>
98
+ <p>Negative: {data['sentiment_overview']['negative']}%</p>
99
+ <div class="image">
100
+ <img src="sentiment_pie_chart.png" width="500">
101
+ </div>
102
+ </div>
103
+
104
+ <div class="section">
105
+ <h2>Network Influence Graph</h2>
106
+ <div class="image">
107
+ <img src="network_graph.png" width="600">
108
+ </div>
109
+ </div>
110
+
111
+ <div class="section">
112
+ <h2>Risk Flags</h2>
113
+ <ul>
114
+ {''.join([f"<li>{flag}</li>" for flag in data["risk_flags"]])}
115
+ </ul>
116
+ </div>
117
+
118
+ <div class="section">
119
+ <h2>Timestamp Range</h2>
120
+ <p>From: {data["timestamp_range"]["from"]}</p>
121
+ <p>To: {data["timestamp_range"]["to"]}</p>
122
+ </div>
123
+ </body>
124
+ </html>
125
+ """
126
+
127
+ with open("/mnt/data/OSINT_Report.html", "w", encoding="utf-8") as f:
128
+ f.write(html_content)