trending_to_gtrend.py 513 B

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