Commit 8744fcfb authored by lixiaofang's avatar lixiaofang

add

parent dcb2458f
This diff is collapsed.
...@@ -21,7 +21,6 @@ def get_topic_id(numtime1, numtime2): ...@@ -21,7 +21,6 @@ def get_topic_id(numtime1, numtime2):
) )
data = cursor.fetchall() data = cursor.fetchall()
topic_id = list(data) topic_id = list(data)
logging.info("Database version : %s " % topic_id)
topic_id_list = [] topic_id_list = []
if topic_id: if topic_id:
for i in topic_id: for i in topic_id:
...@@ -63,8 +62,6 @@ if __name__ == "__main__": ...@@ -63,8 +62,6 @@ if __name__ == "__main__":
else: else:
dicts[i[1]].append(i[0]) dicts[i[1]].append(i[0])
logging.info("get dicts:%s" % dicts)
for key, value in dicts.items(): for key, value in dicts.items():
rand_num = random.randint(0, len(value) - 1) rand_num = random.randint(0, len(value) - 1)
...@@ -73,8 +70,6 @@ if __name__ == "__main__": ...@@ -73,8 +70,6 @@ if __name__ == "__main__":
comment = get_comment() comment = get_comment()
logging.info("get comment:%s" % comment)
for i in range(1): for i in range(1):
time.sleep(random.randint(10, 20)) time.sleep(random.randint(10, 20))
......
...@@ -10,22 +10,22 @@ from auto_request import login, time_convs, follow, get_user_id ...@@ -10,22 +10,22 @@ from auto_request import login, time_convs, follow, get_user_id
from auto_request import host, user, port, db, passwd from auto_request import host, user, port, db, passwd
def get_topic_new_user(numtime): def get_topic_new_user(numtime1, numtime2):
try: try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port) pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=port)
cursor = pc.cursor() cursor = pc.cursor()
cursor.execute( cursor.execute(
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' " % numtime) "SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time > '%s' " % numtime1)
topic_data = cursor.fetchall() topic_data = cursor.fetchall()
cursor.execute( cursor.execute(
"SELECT distinct(user_id) FROM group_user_role WHERE create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT distinct(user_id) FROM group_user_role WHERE create_time > '%s'" % numtime1)
new_user_data = cursor.fetchall() new_user_data = cursor.fetchall()
topic_data = list(topic_data) topic_data = list(topic_data)
new_user_data = list(new_user_data) new_user_data = list(new_user_data)
topic_id_list = [] topic_id_list = []
if topic_data : if topic_data:
for i in topic_data: for i in topic_data:
cursor.execute( cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0") "select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
...@@ -54,26 +54,24 @@ def get_topic_new_user(numtime): ...@@ -54,26 +54,24 @@ def get_topic_new_user(numtime):
if __name__ == "__main__": if __name__ == "__main__":
try: try:
numtime = time_convs(0) numtime1, numtime2 = time_convs(1, 1)
user_id = get_topic_new_user(numtime) user_id = get_topic_new_user(numtime1)
follow_num = random.randint(1, 2) follow_num = random.randint(1, 2)
for i in range(follow_num): for i in range(follow_num):
if user_id: for j in user_id and user_id:
for j in user_id: id = int(j[0])
id = int(j[0]) time.sleep(random.randint(10, 30))
time.sleep(random.randint(10, 30)) cookies = login()
cookies = login() if cookies is not None:
follow(cookies, id)
if cookies is not None:
follow(cookies, id)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -14,6 +14,16 @@ ...@@ -14,6 +14,16 @@
# #
# print(yes_time_str) # print(yes_time_str)
# print(yes_time_str2) # print(yes_time_str2)
import random # import random
rand_num = random.randint(0,2) # rand_num = random.randint(0,2)
print(rand_num) # print(rand_n
\ No newline at end of file #
# um)
import datetime
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=1)
yes_time_str = yes_time.strftime('%Y-%m-%d')
yes_time_str = yes_time_str + ' 23:59:59.000000'
print(yes_time_str)
\ No newline at end of file
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