123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import sys
- import codecs
- import traceback
- import re
- import pandas as pd
- import random
- import os
- import redis
- import time
- import json
- import fire
- import dataset
- import pymysql
- pymysql.install_as_MySQLdb()
- def run_once():
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
- lst = ['倉儲管理 神助移動貨架', '倉儲管理 神助貨架', '倉儲 管理']
- # cursor = db.query('select term, domain from seo.selected_kw where client="仁本"')
- # for c in cursor:
- # lst.append([c['term'], c['domain']])
- obj = random.choice(lst)
- kw = obj
- domain = 'jiatetea.tw'
- print(kw, domain)
- os.chdir('C:\/Users\/s1301\/PycharmProjects\/kw_tools\/INNNews')
- intval = os.system(f'python3 general_clickbot_local.py get --kw="{kw}" --domain="{domain}"')
- print('執行完成genetal_clickbot')
- if intval == -1:
- print('-1')
- sys.exit()
- db.close()
- def run_specific():
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
- # db_local = dataset.connect('mysql://root:jondae350@localhost/ig_tags')
- lst = []
- ####形象SEO####
- # cursor = db.query('select json from seo.seo_jobs where id between 937 and 946')
- # for c in cursor:
- # print(c['json'])
- # js = json.loads(c['json'])
- # prefix = js['prefix']
- # postfix = js['postfix']
- # domain = js['domain'][0]
- # positive = js['positive']
- # rnd = js['rnd']
- # kw1 = random.choice(positive)
- # kw2 = random.choice(rnd)
- # kw = prefix + " " + kw1 + " " + kw2
- # # print(kw, domain)
- ###形象SEO###
- cursor = db.query('select term, domain from seo.selected_kw where client="plantA"')
- for c in cursor:
- lst.append([c['term'], c['domain']])
- obj = random.choice(lst)
- kw = obj[0]
- domain = obj[1]
- print(kw, domain)
- intval = os.system(f'python3 general_clickbot_local.py get --kw="{kw}" --domain="{domain}"')
- print('執行完成genetal_clickbot')
- if intval == -1:
- print('-1')
- sys.exit()
- db.close()
- # run_specific()
- while True:
- # run_once()
- run_specific()
- time.sleep(random.randint(120, 150))
|