Your Name 3 年之前
父節點
當前提交
eb39a99f93
共有 1 個文件被更改,包括 73 次插入0 次删除
  1. 73 0
      choozmo/igool/igtree.py

+ 73 - 0
choozmo/igool/igtree.py

@@ -0,0 +1,73 @@
+import suggests
+import networkx as nx
+import pyvis
+import time
+from pyvis.network import Network
+import pickle
+
+
+#kw='覆髓'p
+#kw='塗氟'
+#kw='口掃機'
+#kw='牙醫助理'
+#kw='牙材'
+#kw='牙醫師公會'
+#kw='防齲'
+#kw='齒模'
+#kw='金屬牙套'
+#kw='醫療法'
+#kw='牙醫師手冊'
+#kw='貝氏刷牙'
+#kw='牙醫積分'
+#kw='牙醫師'
+#kw='牙醫全聯會'
+#kw='牙醫系'
+#kw='台大牙醫'
+#kw='成大牙醫'
+#kw='陽明牙醫'
+#kw='北醫牙醫'
+#kw='醫學系公費生'
+#kw='醫學系自費生'
+#kw='北醫牙醫'
+
+#kw='牙醫學會'
+#kw='牙醫總額'
+#kw='牙醫健保'
+#kw='文化資產'
+#kw='藝文團體'
+#kw='書房 設計'
+#kw='室內設計'
+#kw='2021風水擺設'
+#kw='電視牆'
+#kw='系統櫃'
+#kw='收納'
+kw='巧克力'
+
+#kw='廣告投放策略'
+
+s = suggests.suggests.get_suggests(kw, source='google')
+G = nx.Graph()
+#G = pickle.load( open( "gs2.p", "rb" ) )
+
+
+for sg in s['suggests']:
+    G.add_edge(kw,sg,weight=1)
+
+    print(sg)
+    time.sleep(1)
+    s2 = suggests.suggests.get_suggests(sg, source='google')
+    for elmt in s2['suggests']:
+        G.add_edge(sg,elmt,weight=1)
+
+
+G.remove_edges_from( list(nx.selfloop_edges(G)))
+
+pickle.dump( G, open( "gs2.p", "wb" ) )
+
+pyG = Network(height="750px", width="100%",bgcolor="#333333",font_color="white")
+pyG.from_nx(G)
+pyG.show('gs.html')
+
+
+
+