Commit 0db2fe2e authored by lixiaofang's avatar lixiaofang

add

parent 7af0a79f
...@@ -8,105 +8,103 @@ import logging ...@@ -8,105 +8,103 @@ import logging
from celery import shared_task from celery import shared_task
from django.conf import settings from django.conf import settings
from majia.get_session import get_comments, click, login, reply from majia.get_session import get_comments, click, login, reply
# from majia.get_session import host, user, passwd, db from majia.get_session import host, user, passwd, db
exec_count = 0 exec_count = 0
def auto_click(pk_list): def auto_click(pk_list):
print(pk_list)
# exec_count = 0 exec_count = 0
# try: try:
# pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306) pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
# cursor = pc.cursor() cursor = pc.cursor()
# cursor.execute( cursor.execute(
# "SELECT id,user_id FROM topic WHERE id in " + str( "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)") tuple(pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
# data = cursor.fetchall() data = cursor.fetchall()
# topic_id_list = list(data) topic_id_list = list(data)
# logging.info("Database version : %s " % topic_id_list) logging.info("Database version : %s " % topic_id_list)
# pc.close() pc.close()
# exec_count = 0 exec_count = 0
# if topic_id_list: if topic_id_list:
#
# def fun_timer(): def fun_timer():
# cookies = login() cookies = login()
# if cookies: if cookies:
# click(cookies, topic_id_list[0]) click(cookies, topic_id_list[0])
#
# global timer global timer
# global exec_count global exec_count
#
# exec_count += 1 exec_count += 1
# if exec_count == 1: if exec_count == 1:
# # sleep_time = random.randint(300, 540) # sleep_time = random.randint(300, 540)
# sleep_time = 30 sleep_time = 30
# timer = threading.Timer(sleep_time, fun_timer) timer = threading.Timer(sleep_time, fun_timer)
# timer.start() timer.start()
#
# if exec_count == 2: if exec_count == 2:
# # sleep_time = random.randint(1000, 1900) # sleep_time = random.randint(1000, 1900)
# sleep_time = 50 sleep_time = 50
# timer = threading.Timer(sleep_time, fun_timer) timer = threading.Timer(sleep_time, fun_timer)
# timer.start() timer.start()
#
# sleep_time = random.randint(300, 540) sleep_time = random.randint(300, 540)
# timer = threading.Timer(10, fun_timer) # 首次启动 timer = threading.Timer(10, fun_timer) # 首次启动
# timer.start() timer.start()
#
# else: else:
# pass pass
# except: except:
# logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
def auto_reply(pk_list): def auto_reply(pk_list):
print(pk_list) exec_count = 0
try:
# exec_count = 0 pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
# try: cursor = pc.cursor()
# pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306) cursor.execute(
# cursor = pc.cursor() "SELECT id,user_id FROM topic WHERE id in " + str(
# cursor.execute( 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( data = cursor.fetchall()
# tuple(pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0)") topic_id_list = list(data)
# data = cursor.fetchall() logging.info("Database version : %s " % topic_id_list)
# topic_id_list = list(data) pc.close()
# logging.info("Database version : %s " % topic_id_list) exec_count = 0
# pc.close() if topic_id_list:
# exec_count = 0
# if topic_id_list: def fun_comment():
# cookies = login()
# def fun_comment(): if cookies:
# cookies = login() comment_content = get_comments()
# if cookies: comment = comment_content[0]
# comment_content = get_comments() reply(cookies, topic_id_list[0], comment)
# comment = comment_content[0]
# reply(cookies, topic_id_list[0], comment) global timer
# global exec_count
# global timer
# global exec_count exec_count += 1
# if exec_count == 1:
# exec_count += 1 sleep_time = random.randint(300, 540)
# if exec_count == 1: sleep_time = 30
# sleep_time = random.randint(300, 540) timer = threading.Timer(sleep_time, fun_comment)
# sleep_time = 30 timer.start()
# timer = threading.Timer(sleep_time, fun_comment)
# timer.start() if exec_count == 2:
# sleep_time = random.randint(1000, 1900)
# if exec_count == 2: sleep_time = 30
# sleep_time = random.randint(1000, 1900) timer = threading.Timer(sleep_time, fun_comment)
# sleep_time = 30 timer.start()
# timer = threading.Timer(sleep_time, fun_comment)
# timer.start() sleep_time = random.randint(300, 540)
# timer = threading.Timer(10, fun_comment) # 首次启动
# sleep_time = random.randint(300, 540) timer.start()
# timer = threading.Timer(10, fun_comment) # 首次启动
# timer.start()
# except:
# logging.error("catch exception,main:%s" % traceback.format_exc())
# except:
# logging.error("catch exception,main:%s" % traceback.format_exc())
@shared_task @shared_task
......
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