Commit 8efe5979 authored by lixiaofang's avatar lixiaofang

add

parent 01c5508f
This diff is collapsed.
......@@ -8,26 +8,27 @@ 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:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
data = cursor.fetchall()
user_id = list(data)
if user_id:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
return topic_id_list
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()
user_id = list(data)
if user_id:
topic_id_list.append(i)
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,39 +42,39 @@ 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], [])
dicts[i[0]].append(i[1])
if i[0] not in dicts.keys():
dicts.setdefault(i[0], [])
dicts[i[0]].append(i[1])
else:
dicts[i[0]].append(i[1])
else:
dicts[i[0]].append(i[1])
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)
rand_id = value[rand_num]
rand_id = value[rand_num]
urge_num = random.randint(0, 1)
urge_num = random.randint(0, 1)
for i in range(urge_num):
for i in range(urge_num):
time.sleep(random.randint(1, 10))
time.sleep(random.randint(1, 10))
cook = login()
cook = login()
if cook is not None:
click(cook, rand_id)
if cook is not None:
click(cook, rand_id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -9,27 +9,26 @@ 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:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
data = cursor.fetchall()
user_id = list(data)
if user_id:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
return topic_id_list
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()
user_id = list(data)
if user_id:
topic_id_list.append(i)
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())
......@@ -50,35 +49,36 @@ if __name__ == "__main__":
dict = {}
if user_id:
for i in user_id and user_id:
if i[0] not in dict.keys():
dict.setdefault(i[0], [])
for i in user_id:
dict[i[0]].append(i[1])
if i[0] not in dict.keys():
else:
dict[i[0]].append(i[1])
dict.setdefault(i[0], [])
for key, value in dict.items():
dict[i[0]].append(i[1])
rand_num = random.randint(0, len(value) - 1)
else:
dict[i[0]].append(i[1])
rand_id = value[rand_num]
for key, value in dict.items():
urge_num = random.randint(0, 1)
rand_num = random.randint(0, len(value) - 1)
for i in range(urge_num):
rand_id = value[rand_num]
time.sleep(random.randint(1, 10))
urge_num = random.randint(0, 1)
cook = login()
for i in range(urge_num):
if cook is not None:
click(cook, rand_id)
time.sleep(random.randint(1, 10))
cook = login()
if cook is not None:
click(cook, rand_id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -39,48 +39,44 @@ if __name__ == "__main__":
dict_follow_id = {}
if data:
for j in data and data:
for j in data:
if j[2] != None:
if j[2] != None:
if j[0] not in dict_follow_id.keys():
if j[0] not in dict_follow_id.keys():
dict_follow_id.setdefault(j[0], [])
dict_follow_id.setdefault(j[0], [])
dict_follow_id[j[0]].append(j[2])
dict_follow_id[j[0]].append(j[2])
else:
dict_follow_id[j[0]].append(j[2])
else:
dict_follow_id[j[0]].append(j[2])
dict_email = {}
if data:
for j in data:
for j in data and data:
if j[2] != None:
if j[2] != None:
if j[0] not in dict_email.keys():
if j[0] not in dict_email.keys():
dict_email.setdefault(j[0], [])
dict_email.setdefault(j[0], [])
dict_email[j[0]].append(j[1])
dict_email[j[0]].append(j[1])
else:
dict_email[j[0]].append(j[1])
else:
dict_email[j[0]].append(j[1])
for key, value in dict_follow_id.items():
for key, value in dict_follow_id.items():
id = dict_email[key][0]
id = dict_email[key][0]
for i in value:
for i in value:
cookies = login(id)
cookies = login(id)
if cookies is not None:
follow(cookies, i)
if cookies is not None:
follow(cookies, i)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -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