igtree.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import suggests
  2. import networkx as nx
  3. import pyvis
  4. import time
  5. from pyvis.network import Network
  6. import pickle
  7. #kw='覆髓'p
  8. #kw='塗氟'
  9. #kw='口掃機'
  10. #kw='牙醫助理'
  11. #kw='牙材'
  12. #kw='牙醫師公會'
  13. #kw='防齲'
  14. #kw='齒模'
  15. #kw='金屬牙套'
  16. #kw='醫療法'
  17. #kw='牙醫師手冊'
  18. #kw='貝氏刷牙'
  19. #kw='牙醫積分'
  20. #kw='牙醫師'
  21. #kw='牙醫全聯會'
  22. #kw='牙醫系'
  23. #kw='台大牙醫'
  24. #kw='成大牙醫'
  25. #kw='陽明牙醫'
  26. #kw='北醫牙醫'
  27. #kw='醫學系公費生'
  28. #kw='醫學系自費生'
  29. #kw='北醫牙醫'
  30. #kw='牙醫學會'
  31. #kw='牙醫總額'
  32. #kw='牙醫健保'
  33. #kw='文化資產'
  34. #kw='藝文團體'
  35. #kw='書房 設計'
  36. #kw='室內設計'
  37. #kw='2021風水擺設'
  38. #kw='電視牆'
  39. #kw='系統櫃'
  40. #kw='收納'
  41. #kw='軟糖'
  42. kw='手工餅乾'
  43. #kw='廣告投放策略'
  44. #s={'suggests':[]}
  45. s = suggests.suggests.get_suggests(kw, source='google')
  46. #G = nx.Graph()
  47. G = pickle.load( open( "gs2.p", "rb" ) )
  48. #G.remove_node('巧克力囊腫')
  49. #G.remove_node('巧克力雲莊')
  50. for sg in s['suggests']:
  51. G.add_edge(kw,sg,weight=1)
  52. print(sg)
  53. time.sleep(1)
  54. s2 = suggests.suggests.get_suggests(sg, source='google')
  55. for elmt in s2['suggests']:
  56. G.add_edge(sg,elmt,weight=1)
  57. G.remove_nodes_from(list(nx.isolates(G)))
  58. G.remove_edges_from( list(nx.selfloop_edges(G)))
  59. pickle.dump( G, open( "gs2.p", "wb" ) )
  60. pyG = Network(height="750px", width="100%",bgcolor="#333333",font_color="white")
  61. pyG.from_nx(G)
  62. pyG.show('gs.html')