Commit 8efe5979 authored by lixiaofang's avatar lixiaofang

add

parent 01c5508f
This diff is collapsed.
...@@ -8,17 +8,17 @@ from auto_request import login, click, time_convs ...@@ -8,17 +8,17 @@ from auto_request import login, click, time_convs
from auto_request import host, user, db, passwd from auto_request import host, user, db, passwd
def get_data(numtime): def get_data(numtime, numtime2):
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 user_id,id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT user_id,id FROM topic WHERE is_online=1 and create_time > '%s' and create_time < '%s'" % (
numtime, numtime2))
data = cursor.fetchall() data = cursor.fetchall()
topic_id = list(data) topic_id = list(data)
topic_id_list = [] topic_id_list = []
if topic_id: for i in topic_id and topic_id:
for i in topic_id:
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")
data = cursor.fetchall() data = cursor.fetchall()
...@@ -28,6 +28,7 @@ def get_data(numtime): ...@@ -28,6 +28,7 @@ def get_data(numtime):
logging.info("Database version : %s " % topic_id_list) logging.info("Database version : %s " % topic_id_list)
pc.close() pc.close()
return topic_id_list return topic_id_list
except: except:
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return [] return []
...@@ -41,15 +42,15 @@ if __name__ == "__main__": ...@@ -41,15 +42,15 @@ if __name__ == "__main__":
for i in time_list: for i in time_list:
numtime = time_convs(i) numtime,numtime2 = time_convs(i + 1, i - 1)
logging.info("get numtime :%s "%numtime)
logging.info("get numtime2 :%s"%numtime2)
user_id = get_data(numtime) user_id = get_data(numtime,numtime2)
dicts = {} dicts = {}
if user_id: for i in user_id and user_id:
for i in user_id:
if i[0] not in dicts.keys(): if i[0] not in dicts.keys():
dicts.setdefault(i[0], []) dicts.setdefault(i[0], [])
......
...@@ -9,18 +9,17 @@ from auto_request import login, click, time_convs ...@@ -9,18 +9,17 @@ from auto_request import login, click, time_convs
from auto_request import host, user, db, passwd from auto_request import host, user, db, passwd
def get_data(numtime): def get_data(numtime,numtime2):
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 user_id , id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' " % numtime) "SELECT user_id , id FROM topic WHERE is_online=1 and create_time > '%%%%%s%%%%' and create_time < '%%%%%s%%%%' " % (numtime,numtime2))
data = cursor.fetchall() data = cursor.fetchall()
topic_id = list(data) topic_id = list(data)
topic_id_list = [] topic_id_list = []
if topic_id: for i in topic_id and topic_id:
for i in topic_id:
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")
data = cursor.fetchall() data = cursor.fetchall()
...@@ -50,9 +49,7 @@ if __name__ == "__main__": ...@@ -50,9 +49,7 @@ if __name__ == "__main__":
dict = {} dict = {}
if user_id: for i in user_id and user_id:
for i in user_id:
if i[0] not in dict.keys(): if i[0] not in dict.keys():
...@@ -80,5 +77,8 @@ if __name__ == "__main__": ...@@ -80,5 +77,8 @@ if __name__ == "__main__":
if cook is not None: if cook is not None:
click(cook, rand_id) click(cook, rand_id)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -39,9 +39,7 @@ if __name__ == "__main__": ...@@ -39,9 +39,7 @@ if __name__ == "__main__":
dict_follow_id = {} dict_follow_id = {}
if data: for j in data and data:
for j in data:
if j[2] != None: if j[2] != None:
...@@ -56,9 +54,7 @@ if __name__ == "__main__": ...@@ -56,9 +54,7 @@ if __name__ == "__main__":
dict_email = {} dict_email = {}
if data: for j in data and data:
for j in data:
if j[2] != None: if j[2] != None:
......
...@@ -19,9 +19,8 @@ def get_data(numtime): ...@@ -19,9 +19,8 @@ def get_data(numtime):
(numtime)) (numtime))
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
topic_id_list = [] topic_id_list = []
for i in user_id: for i in user_id and user_id:
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 ")
data = cursor.fetchall() data = cursor.fetchall()
...@@ -47,7 +46,7 @@ if __name__ == "__main__": ...@@ -47,7 +46,7 @@ if __name__ == "__main__":
for j in range(urge_num): for j in range(urge_num):
for i in user_id: for i in user_id and user_id:
cookies = get_cookies(i) cookies = get_cookies(i)
......
...@@ -137,12 +137,19 @@ def time_conv(minutest): ...@@ -137,12 +137,19 @@ def time_conv(minutest):
return None return None
def time_convs(numtime): def time_convs(numtime, numtime2):
try: try:
now = datetime.datetime.now() now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime) yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d') yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str yes_time_str = yes_time_str + ' 23:59:59.000000'
yes_time2 = now - datetime.timedelta(days=numtime2)
yes_time_str2 = yes_time2.strftime('%Y-%m-%d')
yes_time_str2 = yes_time_str2 + ' 00:00:00.000000'
return yes_time_str, yes_time_str2
except: except:
return None return None
......
import datetime
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=2)
yes_time_str = yes_time.strftime('%Y-%m-%d')
yes_time_str = yes_time_str+' 23:59:59.000000'
yes_time2 = now - datetime.timedelta(days=0)
yes_time_str2 = yes_time2.strftime('%Y-%m-%d')
yes_time_str2 = yes_time_str2+' 00:00:00.000000'
print(yes_time_str)
print(yes_time_str2)
\ 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