run_sns.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 redis
  16. import time
  17. import fire
  18. import dataset
  19. def run_once(pport, dockername):
  20. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  21. lst = []
  22. cursor = db.query('select * from seo.sns_kw')
  23. for c in cursor:
  24. lst.append([c['term'], c['url'], c['client'], c['domain']])
  25. obj = random.choice(lst)
  26. kw = obj[0]
  27. url = obj[1]
  28. client = obj[2]
  29. domain = obj[3]
  30. print(kw, url)
  31. intval = os.system(f'python3 sns_clickbot.py get --kw="{kw}" --url="{url}" --client="{client}" --port="{str(pport)}" --domain="{domain}"')
  32. print('執行完成genetal_clickbot')
  33. if intval == -1:
  34. print('-1')
  35. sys.exit()
  36. db.close()
  37. class JParams(object):
  38. def get(self, port=9222):
  39. while True:
  40. try:
  41. os.system('docker container restart tiny7')
  42. time.sleep(1)
  43. run_once(9928, 'tiny7')
  44. time.sleep(20)
  45. break
  46. except:
  47. os.system('docker container restart tiny7')
  48. time.sleep(15)
  49. if __name__ == '__main__':
  50. fire.Fire(JParams)