igtree.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #kw='黑巧克力'
  45. #kw='蜜糖吐司'
  46. #kw='舒芙蕾'
  47. #kw='馬卡龍'
  48. #kw='馬林糖'
  49. #kw='檸檬塔'
  50. #kw='泡芙'
  51. kw='mean snapchat'
  52. #kw='留學'
  53. #kw='勞力士'
  54. #kw='白蟻'
  55. #kw='影片製作'
  56. #kw='ai 合成'
  57. #kw='菲律賓'
  58. #kw='生巧克力'
  59. #kw='牛奶巧克力'
  60. #kw='廣告投放策略'
  61. #s={'suggests':[]}
  62. s = suggests.suggests.get_suggests(kw, source='google')
  63. G = nx.Graph()
  64. #G = pickle.load( open( "gs2.p", "rb" ) )
  65. #G.remove_node('巧克力囊腫')
  66. #G.remove_node('巧克力雲莊')
  67. for sg in s['suggests']:
  68. G.add_edge(kw,sg,weight=1)
  69. print(sg)
  70. time.sleep(1)
  71. s2 = suggests.suggests.get_suggests(sg, source='google')
  72. for elmt in s2['suggests']:
  73. G.add_edge(sg,elmt,weight=1)
  74. G.remove_nodes_from(list(nx.isolates(G)))
  75. G.remove_edges_from( list(nx.selfloop_edges(G)))
  76. pickle.dump( G, open( "gs2.p", "wb" ) )
  77. pyG = Network(height="750px", width="100%",bgcolor="#333333",font_color="white")
  78. pyG.from_nx(G)
  79. pyG.show('gs.html')