sug.md 756 B

Google Suggest

import suggests
import networkx as nx
import pyvis
import time
from pyvis.network import Network
import pickle

kw='郁琇琇'
s = suggests.suggests.get_suggests(kw, source='google')
G = nx.Graph()
#G = pickle.load( open( "gs.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( "gs.p", "wb" ) )

pyG = Network(height="750px", width="100%",bgcolor="#333333",font_color="white")
pyG.from_nx(G)
pyG.show('gs.html')

google suggest