Commit 7812ab53 authored by lixiaofang's avatar lixiaofang

add

parent 6cff25b7
......@@ -9,17 +9,20 @@ from celery import shared_task
from django.conf import settings
from majia import get_comments, get_cookies, click, time_conv, login, reply
from majia import host,user,passwd,db
exec_count =0
from majia import host, user, passwd, db
exec_count = 0
@shared_task
def auto_click(pk_list):
exec_count =0
exec_count = 0
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT id,user_id FROM topic WHERE id in " + str(tuple(pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
"SELECT id,user_id FROM topic WHERE id in " + str(
tuple(pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
data = cursor.fetchall()
topic_id_list = list(data)
logging.info("Database version : %s " % topic_id_list)
......@@ -37,12 +40,14 @@ def auto_click(pk_list):
exec_count += 1
if exec_count == 1:
logging.info("-----1-------")
# sleep_time = random.randint(300, 540)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_timer)
timer.start()
if exec_count == 2:
logging.info("-----2-------")
# sleep_time = random.randint(1000, 1900)
sleep_time = 50
timer = threading.Timer(sleep_time, fun_timer)
......@@ -52,10 +57,6 @@ def auto_click(pk_list):
timer = threading.Timer(10, fun_timer) # 首次启动
timer.start()
sleep_time = random.randint(300, 540)
timer = threading.Timer(10, fun_timer) # 首次启动
timer.start()
else:
pass
except:
......@@ -64,11 +65,13 @@ def auto_click(pk_list):
@shared_task
def auto_reply(pk_list):
exec_count = 0
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT id,user_id FROM topic WHERE id in " + str(tuple(pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
"SELECT id,user_id FROM topic WHERE id in " + str(
tuple(pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
data = cursor.fetchall()
topic_id_list = list(data)
logging.info("Database version : %s " % topic_id_list)
......@@ -90,12 +93,14 @@ def auto_reply(pk_list):
exec_count += 1
if exec_count == 1:
logging.info("-----13-------")
sleep_time = random.randint(300, 540)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_comment)
timer.start()
if exec_count == 2:
logging.info("-----14-------")
sleep_time = random.randint(1000, 1900)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_comment)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment