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')




