Commit 8c673fe3 authored by lixiaofang's avatar lixiaofang

add

parent 6e5b6d60
This diff is collapsed.
...@@ -30,7 +30,7 @@ def get_data(numtime): ...@@ -30,7 +30,7 @@ def get_data(numtime):
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 None return []
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -19,20 +19,21 @@ def get_data(numtime): ...@@ -19,20 +19,21 @@ def get_data(numtime):
data = cursor.fetchall() data = cursor.fetchall()
topic_id = list(data) topic_id = list(data)
topic_id_list = [] topic_id_list = []
for i in topic_id: if topic_id:
cursor.execute( for i in topic_id:
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0") cursor.execute(
data = cursor.fetchall() "select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
user_id = list(data) data = cursor.fetchall()
if user_id: user_id = list(data)
topic_id_list.append(i) if user_id:
logging.info("Database version : %s " % topic_id_list) topic_id_list.append(i)
pc.close() logging.info("Database version : %s " % topic_id_list)
return topic_id_list pc.close()
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 None return []
if __name__ == "__main__": if __name__ == "__main__":
...@@ -49,33 +50,35 @@ if __name__ == "__main__": ...@@ -49,33 +50,35 @@ if __name__ == "__main__":
dict = {} dict = {}
for i in user_id: if user_id:
for i in user_id:
if i[0] not in dict.keys(): if i[0] not in dict.keys():
dict.setdefault(i[0], []) dict.setdefault(i[0], [])
dict[i[0]].append(i[1]) dict[i[0]].append(i[1])
else: else:
dict[i[0]].append(i[1]) dict[i[0]].append(i[1])
for key, value in dict.items(): for key, value in dict.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: 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())
...@@ -22,20 +22,21 @@ def get_topic_id(numtime): ...@@ -22,20 +22,21 @@ def get_topic_id(numtime):
topic_id = list(data) topic_id = list(data)
logging.info("Database version : %s " % topic_id) logging.info("Database version : %s " % topic_id)
topic_id_list = [] topic_id_list = []
for i in topic_id: if topic_id:
cursor.execute( for i in topic_id:
"select user_id from user_extra where user_id =" + str(i[1]) + " and is_shadow =0 ") cursor.execute(
data = cursor.fetchall() "select user_id from user_extra where user_id =" + str(i[1]) + " and is_shadow =0 ")
user_id = list(data) data = cursor.fetchall()
if user_id: user_id = list(data)
topic_id_list.append(i) if user_id:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close() logging.info("Database version : %s " % topic_id_list)
return topic_id_list pc.close()
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 None return []
if __name__ == "__main__": if __name__ == "__main__":
...@@ -52,41 +53,43 @@ if __name__ == "__main__": ...@@ -52,41 +53,43 @@ if __name__ == "__main__":
dicts = {} dicts = {}
for i in topic_id: if topic_id:
for i in topic_id:
if i[1] not in dicts.keys(): if i[1] not in dicts.keys():
dicts.setdefault(i[1], []) dicts.setdefault(i[1], [])
dicts[i[1]].append(i[0]) dicts[i[1]].append(i[0])
else: else:
dicts[i[1]].append(i[0]) dicts[i[1]].append(i[0])
logging.info("get dicts:%s" % dicts) 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)
rand_id = value[rand_num] rand_id = value[rand_num]
comment = get_comment() comment = get_comment()
logging.info("get comment:%s" % 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))
cook = login() cook = login()
print(cook) print(cook)
if cook is not None: if cook is not None:
reply(cook, key, comment) reply(cook, key, comment)
time.sleep(300) time.sleep(300)
except: except:
logging.error("catch exception,main :%s" % traceback.format_exc()) logging.error("catch exception,main :%s" % traceback.format_exc())
...@@ -25,28 +25,30 @@ def get_topic_new_user(numtime): ...@@ -25,28 +25,30 @@ def get_topic_new_user(numtime):
new_user_data = list(new_user_data) new_user_data = list(new_user_data)
topic_id_list = [] topic_id_list = []
for i in topic_data: if topic_data :
cursor.execute( for i in topic_data:
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0") cursor.execute(
data = cursor.fetchall() "select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
user_id = list(data) data = cursor.fetchall()
if user_id: user_id = list(data)
topic_id_list.append(i) if user_id:
topic_id_list.append(i)
for i in new_user_data:
cursor.execute( if new_user_data:
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0") for i in new_user_data:
data = cursor.fetchall() cursor.execute(
user_id = list(data) "select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
if user_id: data = cursor.fetchall()
topic_id_list.append(i) user_id = list(data)
if user_id:
logging.info("Database version : %s " % topic_id_list) topic_id_list.append(i)
pc.close()
return topic_id_list logging.info("Database version : %s " % topic_id_list)
pc.close()
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 None return []
if __name__ == "__main__": if __name__ == "__main__":
...@@ -60,16 +62,18 @@ if __name__ == "__main__": ...@@ -60,16 +62,18 @@ if __name__ == "__main__":
for i in range(follow_num): for i in range(follow_num):
for j in user_id: if 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: if cookies is not None:
follow(cookies, id) follow(cookies, id)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -19,19 +19,20 @@ def get_data(numtime): ...@@ -19,19 +19,20 @@ def get_data(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: if user_id:
cursor.execute( for i in user_id:
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0") cursor.execute(
data = cursor.fetchall() "select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
id = list(data) data = cursor.fetchall()
if id: id = list(data)
topic_id_list.append(i) if id:
logging.info("Database version : %s " % topic_id_list) topic_id_list.append(i)
pc.close() logging.info("Database version : %s " % topic_id_list)
return topic_id_list pc.close()
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 None return []
if __name__ == "__main__": if __name__ == "__main__":
...@@ -52,17 +53,19 @@ if __name__ == "__main__": ...@@ -52,17 +53,19 @@ if __name__ == "__main__":
for i in range(follow_num): for i in range(follow_num):
for j in user_id: if user_id:
id = int(j[0]) for j in user_id:
time.sleep(random.randint(1, 10)) id = int(j[0])
cookies = login() time.sleep(random.randint(1, 10))
if cookies is not None: cookies = login()
follow(cookies, id)
time.sleep(300) if cookies is not None:
follow(cookies, id)
time.sleep(300)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -26,7 +26,7 @@ def get_follw_majia(numtime): ...@@ -26,7 +26,7 @@ def get_follw_majia(numtime):
return data return data
except: except:
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return []
if __name__ == "__main__": if __name__ == "__main__":
...@@ -39,44 +39,48 @@ if __name__ == "__main__": ...@@ -39,44 +39,48 @@ if __name__ == "__main__":
dict_follow_id = {} dict_follow_id = {}
for j in data: if data:
if j[2] != None: for j in data:
if j[0] not in dict_follow_id.keys(): if j[2] != None:
dict_follow_id.setdefault(j[0], []) if j[0] not in dict_follow_id.keys():
dict_follow_id[j[0]].append(j[2]) dict_follow_id.setdefault(j[0], [])
else: 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])
dict_email = {} dict_email = {}
for j in data: if data:
for j in 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: else:
dict_email[j[0]].append(j[1]) 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: if cookies is not None:
follow(cookies, i) follow(cookies, i)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -50,7 +50,7 @@ def get_commnet_id(numtime): ...@@ -50,7 +50,7 @@ def get_commnet_id(numtime):
data_reply = list(data_reply_reply) data_reply = list(data_reply_reply)
topic_id_list = [] topic_id_list = []
for i in data_id: for i in data_id and data_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()
...@@ -58,7 +58,7 @@ def get_commnet_id(numtime): ...@@ -58,7 +58,7 @@ def get_commnet_id(numtime):
if user_id: if user_id:
topic_id_list.append(i) topic_id_list.append(i)
for i in data1_id: for i in data1_id and data1_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()
...@@ -66,7 +66,7 @@ def get_commnet_id(numtime): ...@@ -66,7 +66,7 @@ def get_commnet_id(numtime):
if user_id: if user_id:
topic_id_list.append(i) topic_id_list.append(i)
for i in data2_id: for i in data2_id and data2_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()
...@@ -74,7 +74,7 @@ def get_commnet_id(numtime): ...@@ -74,7 +74,7 @@ def get_commnet_id(numtime):
if user_id: if user_id:
topic_id_list.append(i) topic_id_list.append(i)
for i in data3_id: for i in data3_id and data3_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()
...@@ -82,15 +82,7 @@ def get_commnet_id(numtime): ...@@ -82,15 +82,7 @@ def get_commnet_id(numtime):
if user_id: if user_id:
topic_id_list.append(i) topic_id_list.append(i)
for i in data1_id: for i in data_reply and data_reply:
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)
for i in data_reply:
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()
...@@ -113,7 +105,7 @@ if __name__ == "__main__": ...@@ -113,7 +105,7 @@ if __name__ == "__main__":
user_id = get_commnet_id(numtime) user_id = get_commnet_id(numtime)
for j in user_id: for j in user_id and user_id:
id = int(j[0]) id = int(j[0])
......
...@@ -19,7 +19,7 @@ def get_data(numtime): ...@@ -19,7 +19,7 @@ def get_data(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()
...@@ -42,7 +42,7 @@ if __name__ == "__main__": ...@@ -42,7 +42,7 @@ if __name__ == "__main__":
user_id = get_data(numtime) user_id = get_data(numtime)
urge_num = random.randint(0, 1) urge_num = random.randint(0, 1)
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:
id = int(i[0]) id = int(i[0])
time.sleep(random.randint(10, 30)) time.sleep(random.randint(10, 30))
cook = login() cook = login()
......
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