Commit 53be1169 authored by lixiaofang's avatar lixiaofang

add

parent a840c8d8
This diff is collapsed.
...@@ -7,7 +7,7 @@ import pandas as pd ...@@ -7,7 +7,7 @@ import pandas as pd
import traceback import traceback
from log_settings import * from log_settings import *
import logging import logging
from auto_request import get_offline_comment, login, click from auto_request import login, click,get_comments,reply
import threading import threading
from auto_request import host, user, db, passwd from auto_request import host, user, db, passwd
...@@ -18,7 +18,8 @@ if __name__ == "__main__": ...@@ -18,7 +18,8 @@ if __name__ == "__main__":
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 = " + str(927745) + " and user_id in (select user_id from user_extra where is_shadow = 0)") "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() 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)
...@@ -28,10 +29,35 @@ if __name__ == "__main__": ...@@ -28,10 +29,35 @@ if __name__ == "__main__":
exec_count = 0 exec_count = 0
if topic_id_list: 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()
def fun_timer(): def fun_timer():
cookies = login() cookies = login()
if cookies: if cookies:
click(cookies, topic_id_list) click(cookies, topic_id_list[0])
global timer global timer
global exec_count global exec_count
...@@ -49,7 +75,11 @@ if __name__ == "__main__": ...@@ -49,7 +75,11 @@ if __name__ == "__main__":
timer.start() 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 = threading.Timer(10, fun_timer) # 首次启动
timer.start() timer.start()
......
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