gtree2.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. s = suggests.suggests.get_suggests(kw, source='google')
  44. G = nx.Graph()
  45. #G = pickle.load( open( "gs2.p", "rb" ) )
  46. for sg in s['suggests']:
  47. G.add_edge(kw,sg,weight=1)
  48. print(sg)
  49. time.sleep(1)
  50. s2 = suggests.suggests.get_suggests(sg, source='google')
  51. for elmt in s2['suggests']:
  52. G.add_edge(sg,elmt,weight=1)
  53. G.remove_edges_from( list(nx.selfloop_edges(G)))
  54. pickle.dump( G, open( "gs2.p", "wb" ) )
  55. pyG = Network(height="750px", width="100%",bgcolor="#333333",font_color="white")
  56. pyG.from_nx(G)
  57. pyG.show('gs.html')