import gtrendtest_jsraw import dataset import time db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/gtrends?charset=utf8mb4') cursor=db.query('SELECT distinct qtitle FROM gtrends.trending_search_flat where qtitle not in (select original from kw_related)') lst=[] for c in cursor: print(c['qtitle']) lst.append(c['qtitle']) for l in lst: sgtrend=gtrendtest_jsraw.SelGTrend() data=sgtrend.search(l) time.sleep(5) #data=sgtrend.search('居家') #data=sgtrend.search('7-11 當機')