Commit 2703571b authored by lixiaofang's avatar lixiaofang

add

parent e57e74f3
......@@ -13,26 +13,56 @@ from get_session import get_comments, get_cookies, click, time_conv, login, repl
@shared_task
def auto_click(id):
def auto_click(es_type, id):
try:
cookies = login()
if cookies is not None:
num1 = random.randint(0, 500)
time.sleep(num1)
click(cookies, id)
cookies = login()
if cookies is not None:
num2 = random.randint(1000, 1500)
time.sleep(num2)
click(cookies, id)
cookies = login()
if cookies is not None:
num3 = random.randint(2000, 3000)
time.sleep(num3)
click(cookies, id)
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 = " + str(
id) + " 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)
pc.close()
topic_id_list = 919337
exec_count = 0
if topic_id_list:
def fun_timer():
cookies = login()
if cookies:
click(cookies, topic_id_list[0])
global timer
global exec_count
exec_count += 1
if exec_count == 1:
# sleep_time = random.randint(300, 540)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_timer)
timer.start()
if exec_count == 2:
# sleep_time = random.randint(1000, 1900)
sleep_time = 50
timer = threading.Timer(sleep_time, fun_timer)
timer.start()
sleep_time = random.randint(300, 540)
timer = threading.Timer(10, fun_comment) # 首次启动
timer.start()
sleep_time = random.randint(300, 540)
timer = threading.Timer(10, fun_timer) # 首次启动
timer.start()
else:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -40,30 +70,47 @@ def auto_click(id):
@shared_task
def auto_reply(id):
try:
cookies = login()
if cookies:
time.sleep(random.randint(0, 500))
num1 = random.randint(0, 500)
time.sleep(num1)
comment_content = get_comments()
comment = comment_content[0]
reply(cookies, id, comment)
cookies = login()
if cookies:
num2 = random.randint(1000, 1500)
time.sleep(num2)
comment_content = get_comments()
comment = comment_content[0]
reply(cookies, id, comment)
cookies = login()
if cookies:
num3 = random.randint(2000, 3500)
time.sleep(num3)
comment_content = get_comments()
comment = comment_content[0]
reply(cookies, id, comment)
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 = " + str(
id) + " 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)
pc.close()
topic_id_list = 919337
exec_count = 0
if topic_id_list:
def fun_comment():
cookies = login()
if cookies:
comment_content = get_comments()
comment = comment_content[0]
reply(cookies, id, comment)
global timer
global exec_count
exec_count += 1
if exec_count == 1:
sleep_time = random.randint(300, 540)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_comment)
timer.start()
if exec_count == 2:
sleep_time = random.randint(1000, 1900)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_comment)
timer.start()
sleep_time = random.randint(300, 540)
timer = threading.Timer(10, fun_comment) # 首次启动
timer.start()
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......
......@@ -113,17 +113,15 @@ def get_comments():
list_guanshui = []
for i in data:
list_guanshui.append(i)
num1 = random.randint(0, 500)
num2 = random.randint(500, 1000)
num3 = random.randint(1000, 1500)
num4 = random.randint(1500, len(list_guanshui))
num1 = random.randint(0, 30)
num2 = random.randint(30, 70)
num4 = random.randint(70, len(list_guanshui))
comment1 = list_guanshui[num1 - 1]
comment2 = list_guanshui[num2 - 1]
comment3 = list_guanshui[num3 - 1]
comment4 = list_guanshui[num4 - 1]
comment_list = [comment1, comment2, comment3, comment4]
comment_list = [comment1, comment2, comment3]
return comment_list
except:
......
......@@ -15,9 +15,9 @@ class CeleryTaskRouter(object):
"majia-alpha": [
'injection.data_sync.auto_instant_click.auto_click',
]
}
# Map[TaskName, QueueName]
task_queue_map = dict(itertools.chain.from_iterable(
[(task, queue) for task in task_list]
......
......@@ -57,6 +57,7 @@ CELERYBEAT_SCHEDULE = {
'args': ()
},
}
"""
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
......
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