Commit 5e4d6a92 authored by lixiaofang's avatar lixiaofang

add

parent b8d46e05
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/auto_commnet.py" charset="GBK" />
<file url="file://$PROJECT_DIR$/auto_comment.py" charset="GBK" />
<file url="file://$PROJECT_DIR$/comment.txt" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
import time
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, click, time_convs
from auto_request import host, user, db, passwd
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 > '%s' and create_time <= '%s'" % (
numtime, numtime2))
data = cursor.fetchall()
topic_id = list(data)
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 []
if __name__ == "__main__":
try:
time_list = [1,2,3, 4, 5, 6, 7]
for i in time_list:
numtime, numtime2 = time_convs(i + 1, i - 1)
user_id = get_data(numtime, numtime2)
dicts = {}
if user_id:
for i in user_id:
if i[0] not in dicts.keys():
dicts.setdefault(i[0], [])
dicts[i[0]].append(i[1])
else:
dicts[i[0]].append(i[1])
for key, value in dicts.items():
rand_num = random.randint(0, len(value) - 1)
rand_id = value[rand_num]
urge_num = random.randint(0, 1)
for i in range(urge_num):
time.sleep(random.randint(1, 10))
cook = login()
if cook is not None:
click(cook, rand_id)
else:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
\ No newline at end of file
......@@ -15,9 +15,8 @@ def get_data(numtime, numtime2):
logging.info("get numtime:%s" % numtime)
logging.info("get numtime2:%s" % numtime2)
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time > '%s' and create_time < '%s')" % (
"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 = []
......@@ -32,56 +31,22 @@ def get_data(numtime, numtime2):
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
except:
pass
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
def write_id_file(id):
try:
data = open("save_topic_id.txt", "a")
data.write(str(id))
data.write("\n")
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
if __name__ == "__main__":
try:
data1 = open("save_topic_id.txt", "w")
data1.truncate()
numtime, numtime2 = time_conv(5, 0)
numtime, numtime2 = time_conv(15, 5)
user_id = get_data(numtime, numtime2)
dicts = {}
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])
else:
dicts[i[0]].append(i[1])
for key, value in dicts.items():
rand_num = random.randint(0, len(value) - 1)
rand_id = value[rand_num]
time.sleep(random.randint(1, 10))
for i in user_id:
cook = login()
if cook is not None:
write_id_file(rand_id)
click(cook, rand_id)
click(cook, i[1])
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -4,63 +4,51 @@ import random
import traceback
from log_settings import *
import logging
from auto_request import login, click
from auto_request import login, click, time_conv
from auto_request import host, user, db, passwd
def write_id_file():
def get_data(numtime, numtime2):
try:
user_ids = []
data = open("save_topic_id.txt", "r")
data2 = open("save_topic_id_three.txt", "w")
for i in data.readlines():
data2.write(str(i.strip()))
data2.write("\n")
user_ids.append(int(i))
return user_ids
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
logging.info("get numtime:%s" % numtime)
logging.info("get numtime2:%s" % numtime2)
cursor.execute(
"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 = []
logging.info("get topic_id:%s" % topic_id)
try:
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()
except:
pass
return topic_id_list
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
if __name__ == "__main__":
try:
user_ids = write_id_file()
lenn = len(user_ids)
randoms_id = []
if lenn == 1:
time.sleep(random.randint(10, 50))
cook = login()
if cook is not None:
click(cook, user_ids[0])
else:
for i in range(int(lenn / 2)) and lenn > 0:
rand_num = random.randint(0, len(user_ids) - 1)
randoms_id.append(user_ids[rand_num])
if randoms_id:
for i in randoms_id:
time.sleep(random.randint(10, 50))
cook = login()
if cook is not None:
click(cook, i)
numtime, numtime2 = time_conv(27,17)
user_id = get_data(numtime, numtime2)
dicts = {}
for i in user_id:
rand_num = random.randint(0,1)
if rand_num == 1:
cook = login()
if cook is not None:
click(cook, i[1])
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -5,58 +5,51 @@ import traceback
from log_settings import *
import logging
from auto_request import login, click, time_conv
from auto_request import host, user, db, passwd
def write_id_file():
def get_data(numtime, numtime2):
try:
user_ids = []
data = open("save_topic_id_three.txt", "r")
for i in data.readlines():
user_ids.append(int(i.strip()))
data = open("save_topic_id_three.txt", "w")
data.truncate()
return user_ids
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
logging.info("get numtime:%s" % numtime)
logging.info("get numtime2:%s" % numtime2)
cursor.execute(
"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 = []
logging.info("get topic_id:%s" % topic_id)
try:
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()
except:
pass
return topic_id_list
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
if __name__ == "__main__":
try:
user_ids = write_id_file()
lenn = len(user_ids)
randoms_id = []
if lenn == 1:
time.sleep(random.randint(10, 50))
cook = login()
if cook is not None:
click(cook, user_ids[0])
else:
for i in range(int(lenn / 2)):
rand_num = random.randint(0, len(user_ids) - 1)
randoms_id.append(user_ids[rand_num])
if randoms_id:
for i in randoms_id:
time.sleep(random.randint(10, 50))
cook = login()
if cook is not None:
click(cook, i)
logging.info("click three")
numtime, numtime2 = time_conv(45, 35)
user_id = get_data(numtime, numtime2)
dicts = {}
for i in user_id:
rand_num = random.randint(0, 1)
if rand_num == 1:
cook = login()
if cook is not None:
click(cook, i[1])
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import time
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, click, time_conv
from auto_request import host, user, db, passwd
def get_data(numtime, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
logging.info("get numtime:%s" % numtime)
logging.info("get numtime2:%s" % numtime2)
cursor.execute(
"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 = []
logging.info("get topic_id:%s" % topic_id)
try:
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()
except:
pass
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
if __name__ == "__main__":
try:
logging.info("click four")
numtime, numtime2 = time_conv(47,37)
user_id = get_data(numtime, numtime2)
dicts = {}
for i in user_id:
rand_num =random.randint(0,1)
if rand_num == 1:
cook = login()
if cook is not None:
click(cook, i[1])
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
\ No newline at end of file
import time
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, click, time_conv
from auto_request import host, user, db, passwd
def get_data(numtime, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
logging.info("get numtime:%s" % numtime)
logging.info("get numtime2:%s" % numtime2)
cursor.execute(
"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 = []
logging.info("get topic_id:%s" % topic_id)
try:
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()
except:
pass
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
if __name__ == "__main__":
try:
logging.info("click five")
numtime, numtime2 = time_conv(51, 41)
user_id = get_data(numtime, numtime2)
dicts = {}
for i in user_id:
rand_num = random.randint(0, 1)
if rand_num == 1:
cook = login()
if cook is not None:
# write_id_file(i[1])
click(cook, i[1])
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -66,8 +66,5 @@ if __name__ == "__main__":
if cook is not None:
click(cook, rand_id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import time
import pymysql
import random
import traceback
......@@ -41,50 +40,20 @@ def get_data(numtime, numtime2):
return []
def write_id_file(id):
try:
data = open("save_topic_comment_id.txt", "a")
data.write(str(id))
data.write("\n")
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
if __name__ == "__main__":
try:
data1 = open("save_topic_comment_id.txt", "w")
data1.truncate()
numtime1, numtime2 = time_conv(5, 0)
logging.info("comment one")
numtime1, numtime2 = time_conv(15, 5)
user_id = get_data(numtime1, numtime2)
dicts = {}
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 user_id:
for i in user_id:
cook = login()
comment = get_comment()
if cook is not None:
reply(cook, i[1], comment)
else:
dicts[i[0]].append(i[1])
for key, value in dicts.items():
rand_num = random.randint(0, len(value) - 1)
rand_id = value[rand_num]
time.sleep(random.randint(1, 10))
cook = login()
comment = get_comment()
if cook is not None:
write_id_file(rand_id)
reply(cook, rand_id, comment)
else:
logging.error("catch exception,main:%s" % traceback.format_exc())
logging.error("catch exception,main:%s" % traceback.format_exc())
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -4,64 +4,59 @@ import random
import traceback
from log_settings import *
import logging
from auto_request import login, reply, get_comment
from auto_request import login, time_conv, get_comment, reply
from auto_request import host, user, db, passwd
def write_id_file():
def get_data(numtime, numtime2):
try:
print("....")
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 > '%s' and create_time < '%s' )" % (
numtime, numtime2))
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
try:
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)
print(user_id)
if user_id:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return topic_id_list
user_ids = []
data = open("save_topic_comment_id.txt", "r")
data2 = open("save_topic_id_comment_three.txt", "w")
for i in data.readlines():
data2.write(str(i.strip()))
data2.write("\n")
user_ids.append(int(i))
return user_ids
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
if __name__ == "__main__":
try:
user_ids = write_id_file()
lenn = len(user_ids)
randoms_id = []
if lenn == 1:
time.sleep(random.randint(10, 50))
comment = get_comment()
cook = login()
if cook is not None:
reply(cook, user_ids[0], comment)
else:
for i in range(int(lenn / 2)):
rand_num = random.randint(0, len(user_ids) - 1)
randoms_id.append(user_ids[rand_num])
if randoms_id:
for i in randoms_id:
time.sleep(random.randint(10, 50))
comment = get_comment()
logging.info("comment two")
numtime1, numtime2 = time_conv(27, 17)
user_id = get_data(numtime1, numtime2)
dicts = {}
if user_id:
for i in user_id:
rand_num = random.randint(0, 1)
if rand_num == 1:
cook = login()
comment = get_comment()
if cook is not None:
reply(cook, i, comment)
reply(cook, i[1], comment)
else:
logging.error("catch exception,main:%s" % traceback.format_exc())
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -4,65 +4,59 @@ import random
import traceback
from log_settings import *
import logging
from auto_request import login, get_comment, reply
from auto_request import login, time_conv, get_comment, reply
from auto_request import host, user, db, passwd
def write_id_file():
def get_data(numtime, numtime2):
try:
print("....")
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 > '%s' and create_time < '%s' )" % (
numtime, numtime2))
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
try:
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)
print(user_id)
if user_id:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return topic_id_list
user_ids = []
data = open("save_topic_id_comment_three.txt", "r")
for i in data.readlines():
user_ids.append(int(i.strip()))
data = open("save_topic_id_comment_three.txt", "w")
data.truncate()
return user_ids
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
if __name__ == "__main__":
try:
user_ids = write_id_file()
lenn = len(user_ids)
randoms_id = []
if lenn == 1:
time.sleep(random.randint(10, 50))
cook = login()
comment = get_comment()
cook = login()
if cook is not None:
reply(cook, user_ids[0], comment)
else:
for i in range(int(lenn / 2)):
rand_num = random.randint(0, len(user_ids) - 1)
randoms_id.append(user_ids[rand_num])
if randoms_id:
for i in randoms_id:
time.sleep(random.randint(10, 50))
logging.info(" commend three")
numtime1, numtime2 = time_conv(45, 35)
user_id = get_data(numtime1, numtime2)
dicts = {}
if user_id:
for i in user_id:
rand_num = random.randint(0, 1)
if rand_num == 1:
cook = login()
comment = get_comment()
cook = login()
if cook is not None:
reply(cook, i, comment)
reply(cook, i[1], comment)
else:
logging.error("catch exception,main:%s" % traceback.format_exc())
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -53,4 +53,4 @@ if __name__ == "__main__":
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
logging.error("catch exception,main:%s" % traceback.format_exc())
\ No newline at end of file
......@@ -16,7 +16,7 @@ def get_star_user_id(numtime1, numtime2):
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time > '%s' and create_time < '%s' " % (
numtime1, numtime2))
numtime1, numtime2))
data = cursor.fetchall()
user_id_list = list(data)
logging.info("Database version : %s " % user_id_list)
......@@ -46,7 +46,7 @@ if __name__ == "__main__":
numtime1, numtime2 = time_convs(i + 1, i - 1)
user_topic_id = get_star_user_id(numtime1,numtime2)
user_topic_id = get_star_user_id(numtime1, numtime2)
try:
......
......@@ -35,7 +35,6 @@ def get_star_useid(numtime1, numtime2):
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
......
......@@ -36,7 +36,6 @@ def get_data(numtime1,numtime2):
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
......
......@@ -37,7 +37,6 @@ def get_data(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
......@@ -64,4 +63,4 @@ if __name__ == "__main__":
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
logging.error("catch exception,main:%s" % traceback.format_exc())
\ No newline at end of file
import pymysql
import traceback
import logging
......@@ -19,20 +18,12 @@ def get_data():
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
data = get_data()
file = open("user_id.txt","w")
file = open("user_id.txt", "w")
for i in data:
file.write(i[0])
file.write("\n")
......@@ -7,7 +7,7 @@ import logging
from auto_request import get_offline_comment
from auto_request import host, user, db, passwd
auto_reply_url = "http://47.93.162.11:8085/api/v1/reply/create_for_inner"
auto_reply_url = "http://saturn.iyanzhi.com/api/v1/reply/create_for_inner"
def reply(id, content, user_id):
......@@ -56,10 +56,8 @@ if __name__ == "__main__":
try:
time_list = [[0, 10000], [10000, 20000], [20000, 30000], [30000, 40000], [40000, 50000],
[50000, 60000], [60000, 70000], [70000, 80000], [80000, 90000], [90000, 100000]]
# time_list = [[5479344,5479354]]
time_list = [[24373571, 34000000],
[34000001, 45974231]]
user_data = open("/srv/apps/cybertron/user_id.txt", "r")
......@@ -87,7 +85,6 @@ if __name__ == "__main__":
comment_list = get_offline_comment()
comment = comment_list[i]
reply(id[0], comment, user_id)
......
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