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
from auto_request import host, user, db, passwd
def get_data(numtime):
def get_data(numtime, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
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()
topic_id = list(data)
topic_id_list = []
if topic_id:
for i in topic_id:
for i in topic_id and topic_id:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
data = cursor.fetchall()
......@@ -28,6 +28,7 @@ def get_data(numtime):
logging.info("Database version : %s " % topic_id_list)
pc.close()
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
......@@ -41,15 +42,15 @@ if __name__ == "__main__":
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 = {}
if user_id:
for i in user_id:
for i in user_id and user_id:
if i[0] not in dicts.keys():
dicts.setdefault(i[0], [])
......
......@@ -9,18 +9,17 @@ from auto_request import login, click, time_convs
from auto_request import host, user, db, passwd
def get_data(numtime):
def get_data(numtime,numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
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()
topic_id = list(data)
topic_id_list = []
if topic_id:
for i in topic_id:
for i in topic_id and topic_id:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
data = cursor.fetchall()
......@@ -50,9 +49,7 @@ if __name__ == "__main__":
dict = {}
if user_id:
for i in user_id:
for i in user_id and user_id:
if i[0] not in dict.keys():
......@@ -80,5 +77,8 @@ if __name__ == "__main__":
if cook is not None:
click(cook, rand_id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -39,9 +39,7 @@ if __name__ == "__main__":
dict_follow_id = {}
if data:
for j in data:
for j in data and data:
if j[2] != None:
......@@ -56,9 +54,7 @@ if __name__ == "__main__":
dict_email = {}
if data:
for j in data:
for j in data and data:
if j[2] != None:
......
......@@ -19,9 +19,8 @@ def get_data(numtime):
(numtime))
data = cursor.fetchall()
user_id = list(data)
topic_id_list = []
for i in user_id:
for i in user_id and user_id:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0 ")
data = cursor.fetchall()
......@@ -47,7 +46,7 @@ if __name__ == "__main__":
for j in range(urge_num):
for i in user_id:
for i in user_id and user_id:
cookies = get_cookies(i)
......
......@@ -137,12 +137,19 @@ def time_conv(minutest):
return None
def time_convs(numtime):
def time_convs(numtime, numtime2):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
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:
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