run_sheet_3.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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():
  20. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  21. lst = []
  22. cursor = db.query('select term, domain from seo.selected_kw where client not in ("毛怪","hhh")')
  23. for c in cursor:
  24. lst.append([c['term'], c['domain']])
  25. #lst2=[['台灣仁本生命服務團隊','sctt.com.tw']]
  26. obj = random.choice(lst)
  27. kw = obj[0]
  28. domain = obj[1]
  29. print(kw, domain)
  30. db.close()
  31. intval = os.system(f'python3 general_clickbot_proxy.py get --kw="{kw}" --domain="{domain}"')
  32. print('執行完成genetal_clickbot')
  33. if intval == -1:
  34. print('-1')
  35. sys.exit()
  36. def run_specific():
  37. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  38. lst = []
  39. cursor = db.query('select term, domain from seo.selected_kw where client="神助物流"')
  40. for c in cursor:
  41. lst.append([c['term'], c['domain']])
  42. db.close()
  43. obj = random.choice(lst)
  44. print('隨機',obj)
  45. #obj = ['貨架','gs-rack.com']
  46. if obj[0]=='重型 架':
  47. lst_1 = ['重型架 無軌式重型移動','重型架 無軌移動貨架','重型 架 神助物流']
  48. kw = random.choice(lst_1)
  49. elif obj[0]=='貨架':
  50. lst_2=['貨架 無軌式重型移動','貨架 無軌式重型移動貨架','貨架 無軌移動貨架儲存方案']
  51. kw = random.choice(lst_2)
  52. #elif obj[0]=='倉儲 設備':
  53. # kw = '倉儲 設備'
  54. # print(kw)
  55. else:
  56. lst_3=[]
  57. lst_3.append(obj[0]+' 神助物流')
  58. lst_3.append(obj[0])
  59. kw = random.choice(lst_3)
  60. domain = obj[1]
  61. print('執行的關鍵字',kw,domain)
  62. intval = os.system(f'python3 general_clickbot_proxy.py get --kw="{kw}" --domain="{domain}"')
  63. print('執行完成神助genetal_clickbot')
  64. if intval == -1:
  65. print('-1')
  66. sys.exit()
  67. while True:
  68. run_once()
  69. time.sleep(random.randint(180,200))
  70. run_specific()
  71. time.sleep(random.randint(180,200))