hhh_run_sheet.py 724 B

12345678910111213141516171819202122232425262728293031323334
  1. import sys
  2. import codecs
  3. import traceback
  4. import requests
  5. import re
  6. import pandas as pd
  7. import random
  8. import urllib
  9. import json
  10. import gspread
  11. import datetime
  12. from gspread_pandas import Spread, Client
  13. from oauth2client.service_account import ServiceAccountCredentials
  14. import os
  15. import time
  16. import dataset
  17. import pymysql
  18. pymysql.install_as_MySQLdb()
  19. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  20. sql = "SELECT * FROM seo.seo_clickjobs where category='hhh-faq'"
  21. cursor = db.query(sql)
  22. db.close()
  23. all_kw = []
  24. for c in cursor:
  25. all_kw.append(c['kw'])
  26. print(all_kw)
  27. kw=random.choice(all_kw)
  28. print(kw)
  29. os.system('python general_clickbot.py get --kw="' + kw + '" --domain=hhh.com.tw')