123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- 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 cust, json from seo.seo_jobs where cust="啟翔" order by rand() limit 1')
- # cursor = db.query('select cust, json from seo.seo_jobs where cust=""')
- # cursor = db.query('select json from seo.seo_jobs where id between 2775 and 2793')
- ### 測試開始部分 ###
- # 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)
- ### 測試結束部分 ###
- # for c in cursor:
- # js = json.loads(c['json'])
- # prefix = js['prefix']
- # postfix = js['postfix']
- # domain = js['domain'][0]
- # positive = js['positive']
- # rnd = js['rnd']
- # client = c['cust']
- # print(prefix)
- # kw1 = random.choice(positive)
- # kw2 = random.choice(rnd)
- # kw = prefix + " " + kw1 + " " + kw2
- ##########
- # cursor = db.query('select term, domain from seo.selected_kw where client="幸福空間"')
- # for c in cursor:
- # lst.append([c['term'], c['domain']])
- lst = ['裝修預算','裝潢預算']
- domain = 'hhh.com.tw/calculator_request'
- obj = random.choice(lst)
- kw = obj[0]
- client = '幸福空間'
- # domain = obj[1]
- print(kw, domain)
- intval = os.system(f'python3 general_clickbot_local.py get --kw="{kw}" --domain="{domain}" --client="{client}"')
- 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))
- #
|