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 ...@@ -13,26 +13,56 @@ from get_session import get_comments, get_cookies, click, time_conv, login, repl
@shared_task @shared_task
def auto_click(id): def auto_click(es_type, id):
try: 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: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -40,30 +70,47 @@ def auto_click(id): ...@@ -40,30 +70,47 @@ def auto_click(id):
@shared_task @shared_task
def auto_reply(id): def auto_reply(id):
try: try:
cookies = login() pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
if cookies: cursor = pc.cursor()
time.sleep(random.randint(0, 500)) cursor.execute(
num1 = random.randint(0, 500) "SELECT id,user_id FROM topic WHERE id = " + str(
time.sleep(num1) id) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
comment_content = get_comments() data = cursor.fetchall()
comment = comment_content[0] topic_id_list = list(data)
reply(cookies, id, comment) logging.info("Database version : %s " % topic_id_list)
pc.close()
cookies = login()
if cookies: topic_id_list = 919337
num2 = random.randint(1000, 1500) exec_count = 0
time.sleep(num2) if topic_id_list:
comment_content = get_comments()
comment = comment_content[0] def fun_comment():
reply(cookies, id, comment) cookies = login()
if cookies:
cookies = login() comment_content = get_comments()
if cookies: comment = comment_content[0]
num3 = random.randint(2000, 3500) reply(cookies, id, comment)
time.sleep(num3)
comment_content = get_comments() global timer
comment = comment_content[0] global exec_count
reply(cookies, id, comment)
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: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
......
...@@ -113,17 +113,15 @@ def get_comments(): ...@@ -113,17 +113,15 @@ def get_comments():
list_guanshui = [] list_guanshui = []
for i in data: for i in data:
list_guanshui.append(i) list_guanshui.append(i)
num1 = random.randint(0, 500) num1 = random.randint(0, 30)
num2 = random.randint(500, 1000) num2 = random.randint(30, 70)
num3 = random.randint(1000, 1500) num4 = random.randint(70, len(list_guanshui))
num4 = random.randint(1500, len(list_guanshui))
comment1 = list_guanshui[num1 - 1] comment1 = list_guanshui[num1 - 1]
comment2 = list_guanshui[num2 - 1] comment2 = list_guanshui[num2 - 1]
comment3 = list_guanshui[num3 - 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 return comment_list
except: except:
......
...@@ -15,9 +15,9 @@ class CeleryTaskRouter(object): ...@@ -15,9 +15,9 @@ class CeleryTaskRouter(object):
"majia-alpha": [ "majia-alpha": [
'injection.data_sync.auto_instant_click.auto_click', 'injection.data_sync.auto_instant_click.auto_click',
] ]
} }
# Map[TaskName, QueueName] # Map[TaskName, QueueName]
task_queue_map = dict(itertools.chain.from_iterable( task_queue_map = dict(itertools.chain.from_iterable(
[(task, queue) for task in task_list] [(task, queue) for task in task_list]
......
...@@ -57,6 +57,7 @@ CELERYBEAT_SCHEDULE = { ...@@ -57,6 +57,7 @@ CELERYBEAT_SCHEDULE = {
'args': () 'args': ()
}, },
} }
""" """
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', '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