Skip to content

Commit 3267a89

Browse files
authored
Create history.py
1 parent 3b898a5 commit 3267a89

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

moumoubaimifan/history/history.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
hostname_dic = {}
2+
with open("chrome_history.csv", encoding="utf-8") as csvfile:
3+
csv_reader = csv.reader(csvfile)
4+
birth_header = next(csv_reader)
5+
for row in csv_reader:
6+
hostname = parse.urlparse(row[0]).hostname
7+
hostname_dic[hostname] = hostname_dic.get(hostname, 0) + 1
8+
sorted(hostname_dic.items(),key = lambda x:x[1],reverse = True)
9+
10+
11+
c = (
12+
Pie()
13+
.add(
14+
"",
15+
[
16+
list(z)
17+
for z in zip(
18+
list(hostname_dic)[0:10],
19+
list(hostname_dic.values())[0:10],
20+
)
21+
],
22+
center=["40%", "50%"],
23+
)
24+
.set_global_opts(
25+
title_opts=opts.TitleOpts(title="历史记录"),
26+
legend_opts=opts.LegendOpts(type_="scroll", pos_left="80%", orient="vertical"),
27+
)
28+
.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
29+
.render("pie_scroll_legend.html")
30+
)
31+
32+
print(hostname_dic)

0 commit comments

Comments
 (0)