Commit a78a48b1 authored by lixiaofang's avatar lixiaofang

change daima

parent ccdd1f2f
...@@ -24,5 +24,29 @@ ...@@ -24,5 +24,29 @@
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" /> <option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings> </formatting-settings>
</DBN-SQL> </DBN-SQL>
<DBN-PSQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
</code_scheme> </code_scheme>
</component> </component>
\ No newline at end of file
This diff is collapsed.
...@@ -13,31 +13,24 @@ auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create" ...@@ -13,31 +13,24 @@ auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_majia(): def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list = []
list=[]
for i in data: for i in data:
list.append(i.strip('\n').strip(',')) list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
maj = random.randint(1,len(list)) user_id = list[maj - 1]
user_id=list[maj-1]
return user_id return user_id
except: except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None return None
def get_cookies(user_id):
def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -50,21 +43,19 @@ def get_cookies(user_id): ...@@ -50,21 +43,19 @@ def get_cookies(user_id):
for i in list: for i in list:
if user_id == i[0]: if user_id == i[0]:
return (i[1]) return (i[1])
except: except:
return None return None
def login():
def login():
try: try:
user_id=get_majia() user_id = get_majia()
cookies = get_cookies(user_id) cookies = get_cookies(user_id)
if cookies is not None: if cookies is not None:
return {'sessionid': cookies} return {'sessionid': cookies}
except: except:
...@@ -73,8 +64,8 @@ def login(): ...@@ -73,8 +64,8 @@ def login():
return None return None
def click(cookies_get, id):
def click(cookies_get, id):
try: try:
post_dict = { post_dict = {
'type': 0, 'type': 0,
...@@ -90,14 +81,14 @@ def click(cookies_get, id): ...@@ -90,14 +81,14 @@ def click(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def reply(cookies_get,id,content):
def reply(cookies_get, id, content):
try: try:
post_dict={ post_dict = {
'topic_id':id, 'topic_id': id,
'content':content 'content': content
} }
response=requests.post(url=auto_reply_url, response = requests.post(url=auto_reply_url,
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
...@@ -107,6 +98,7 @@ def reply(cookies_get,id,content): ...@@ -107,6 +98,7 @@ def reply(cookies_get,id,content):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(): def time_conv():
try: try:
now = datetime.datetime.now() now = datetime.datetime.now()
...@@ -117,12 +109,15 @@ def time_conv(): ...@@ -117,12 +109,15 @@ def time_conv():
except: except:
return None return None
def get_topic_id(numtime): def get_topic_id(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', passwd='oars152!traipseize738', db = pymysql.connect(host="172.17.40.144", user='work', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute("SELECT id FROM topic WHERE is_online =1 and create_time >= %s" ,(numtime)) cursor.execute(
"SELECT id,user_id FROM topic WHERE is_online =1 and create_time >= %s and user_id in (select user_id from user_extra where is_shadow = 0)",
(numtime))
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
...@@ -132,16 +127,15 @@ def get_topic_id(numtime): ...@@ -132,16 +127,15 @@ def get_topic_id(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
def get_comment(): def get_comment():
try: try:
data = pd.read_csv("guanshui", sep='\n') data = open("/srv/apps/cybertron/guanshui", "r")
num = random.randint(0, len(data))
list_guanshui = [] list_guanshui = []
for i in data['comment scene']: for i in data:
l = i.split('\t') list_guanshui.append(i)
list_guanshui.append(l[0]) num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
comment = list_guanshui[num-1]
return comment return comment
...@@ -149,41 +143,44 @@ def get_comment(): ...@@ -149,41 +143,44 @@ def get_comment():
return None return None
if __name__ == "__main__": if __name__ == "__main__":
try: try:
numtime=time_conv() numtime = time_conv()
topic_id = get_topic_id(numtime) topic_id = get_topic_id(numtime)
click_num = random.randint(1, 3)
for i in range(click_num):
for j in topic_id: for j in topic_id:
id = int(j[0]) id = int(j[0])
click_num = random.randint(1,5)
for i in range(click_num):
cookies = login() cookies = login()
time.sleep(random.randint(1, 10))
click(cookies, id) click(cookies, id)
topic_id = get_topic_id(numtime) time.sleep(300)
for j in topic_id: topic_id = get_topic_id(numtime)
id = int(j[0])
comment_num = random.randint(1, 3) comment_num = random.randint(1, 3)
for i in range(comment_num): for i in range(comment_num):
cookies= login() for j in topic_id:
if cookies is not None: id = int(j[0])
cookies = login()
if cookies is not None:
comment = get_comment() comment = get_comment()
time.sleep(random.randint(1, 10))
reply(cookies, id, comment) reply(cookies, id, comment)
time.sleep(300)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -9,19 +9,19 @@ import logging ...@@ -9,19 +9,19 @@ import logging
auto_click_url = "http://earth.iyanzhi.com/api/v1/like" auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
def get_majia():
def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list=[] list = []
for i in data: for i in data:
list.append(i.strip('\n').strip(',')) list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list)) maj = random.randint(1, len(list))
user_id=list[maj-1] user_id = list[maj - 1]
return user_id return user_id
...@@ -29,10 +29,10 @@ def get_majia(): ...@@ -29,10 +29,10 @@ def get_majia():
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None return None
def get_cookies(user_id):
def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -45,21 +45,19 @@ def get_cookies(user_id): ...@@ -45,21 +45,19 @@ def get_cookies(user_id):
for i in list: for i in list:
if user_id == i[0]: if user_id == i[0]:
return (i[1]) return (i[1])
except: except:
return None return None
def login():
def login():
try: try:
user_id=get_majia() user_id = get_majia()
cookies = get_cookies(user_id) cookies = get_cookies(user_id)
if cookies is not None: if cookies is not None:
return {'sessionid': cookies} return {'sessionid': cookies}
except: except:
...@@ -68,8 +66,8 @@ def login(): ...@@ -68,8 +66,8 @@ def login():
return None return None
def click(cookies_get, id):
def click(cookies_get, id):
try: try:
post_dict = { post_dict = {
'type': 0, 'type': 0,
...@@ -85,6 +83,7 @@ def click(cookies_get, id): ...@@ -85,6 +83,7 @@ def click(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime): def time_conv(numtime):
try: try:
now = datetime.datetime.now() now = datetime.datetime.now()
...@@ -94,13 +93,15 @@ def time_conv(numtime): ...@@ -94,13 +93,15 @@ def time_conv(numtime):
except: except:
return None return None
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute("SELECT user_id,id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute(
"SELECT distinct(user_id),id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
...@@ -110,11 +111,12 @@ def get_data(numtime): ...@@ -110,11 +111,12 @@ def get_data(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
if __name__ == "__main__": if __name__ == "__main__":
try: try:
time_list = [1,2,3,4,5,6,7] time_list = [1, 2, 3, 4, 5, 6, 7]
for i in time_list: for i in time_list:
...@@ -122,20 +124,20 @@ if __name__ == "__main__": ...@@ -122,20 +124,20 @@ if __name__ == "__main__":
user_id = get_data(numtime) user_id = get_data(numtime)
dict = {} dicts = {}
for i in user_id: for i in user_id:
if i[0] not in dict.keys(): if i[0] not in dicts.keys():
dict.setdefault(i[0], []) dicts.setdefault(i[0], [])
dict[i[0]].append(i[1]) dicts[i[0]].append(i[1])
else: else:
dict[i[0]].append(i[1]) dicts[i[0]].append(i[1])
print(dicts)
for key, value in dicts.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]
...@@ -143,18 +145,12 @@ if __name__ == "__main__": ...@@ -143,18 +145,12 @@ if __name__ == "__main__":
for i in range(urge_num): for i in range(urge_num):
# time.sleep(random.randint(10, 50)) 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())
...@@ -4,23 +4,23 @@ import datetime ...@@ -4,23 +4,23 @@ import datetime
import pymysql import pymysql
import random import random
import traceback import traceback
from log_settings import *
import logging import logging
auto_click_url = "http://earth.iyanzhi.com/api/v1/like" auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
def get_majia():
def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list=[] list = []
for i in data: for i in data:
list.append(i.strip('\n').strip(',')) list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list)) maj = random.randint(1, len(list))
user_id=list[maj-1] user_id = list[maj - 1]
return user_id return user_id
...@@ -28,10 +28,10 @@ def get_majia(): ...@@ -28,10 +28,10 @@ def get_majia():
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None return None
def get_cookies(user_id):
def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -44,21 +44,19 @@ def get_cookies(user_id): ...@@ -44,21 +44,19 @@ def get_cookies(user_id):
for i in list: for i in list:
if user_id == i[0]: if user_id == i[0]:
return (i[1]) return (i[1])
except: except:
return None return None
def logins():
def logins():
try: try:
user_id=get_majia() user_id = get_majia()
cookies = get_cookies(user_id) cookies = get_cookies(user_id)
if cookies is not None: if cookies is not None:
return {'sessionid': cookies} return {'sessionid': cookies}
except: except:
...@@ -67,8 +65,8 @@ def logins(): ...@@ -67,8 +65,8 @@ def logins():
return None return None
def click(cookies_get, id):
def click(cookies_get, id):
try: try:
post_dict = { post_dict = {
'type': 0, 'type': 0,
...@@ -84,6 +82,7 @@ def click(cookies_get, id): ...@@ -84,6 +82,7 @@ def click(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime): def time_conv(numtime):
try: try:
now = datetime.datetime.now() now = datetime.datetime.now()
...@@ -93,14 +92,16 @@ def time_conv(numtime): ...@@ -93,14 +92,16 @@ def time_conv(numtime):
except: except:
return None return None
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
print("---------") print("---------")
cursor.execute("SELECT user_id,id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute(
"SELECT distinct(user_id),id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
...@@ -110,15 +111,16 @@ def get_data(numtime): ...@@ -110,15 +111,16 @@ def get_data(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
if __name__ == "__main__": if __name__ == "__main__":
try: try:
time_list = [1,2,3,4,5,6,7] time_list = [1, 2, 3, 4, 5, 6, 7]
for i in time_list: for i in time_list:
numtime = time_conv(7+3*i) numtime = time_conv(7 + 3 * i)
user_id = get_data(numtime) user_id = get_data(numtime)
...@@ -135,9 +137,9 @@ if __name__ == "__main__": ...@@ -135,9 +137,9 @@ if __name__ == "__main__":
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]
...@@ -145,12 +147,11 @@ if __name__ == "__main__": ...@@ -145,12 +147,11 @@ if __name__ == "__main__":
for i in range(urge_num): for i in range(urge_num):
time.sleep(random.randint(10, 50)) time.sleep(random.randint(1, 10))
cook=logins() cook = logins()
if cook is not None: if cook is not None:
click(cook, rand_id) click(cook, rand_id)
except: except:
......
...@@ -3,27 +3,24 @@ import time ...@@ -3,27 +3,24 @@ import time
import datetime import datetime
import pymysql import pymysql
import random import random
import pandas as pd
import traceback import traceback
from log_settings import *
import logging import logging
auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create" auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
def get_majia(): def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen.txt")
list=[] list = []
for i in data: for i in data:
list.append(i.strip('\n').strip(',')) list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list)) maj = random.randint(1, len(list))
user_id=list[maj-1] user_id = list[maj - 1]
return user_id return user_id
...@@ -31,10 +28,10 @@ def get_majia(): ...@@ -31,10 +28,10 @@ def get_majia():
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None return None
def get_cookies(user_id):
def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -47,21 +44,19 @@ def get_cookies(user_id): ...@@ -47,21 +44,19 @@ def get_cookies(user_id):
for i in list: for i in list:
if user_id == i[0]: if user_id == i[0]:
return (i[1]) return (i[1])
except: except:
return None return None
def logins():
def logins():
try: try:
user_id=get_majia() user_id = get_majia()
cookies = get_cookies(user_id) cookies = get_cookies(user_id)
if cookies is not None: if cookies is not None:
return {'sessionid': cookies} return {'sessionid': cookies}
except: except:
...@@ -70,65 +65,67 @@ def logins(): ...@@ -70,65 +65,67 @@ def logins():
return None return None
def reply(cookies_get,id,content):
try : def reply(cookies_get, id, content):
post_dict={ try:
'topic_id':id, post_dict = {
'content':content 'topic_id': id,
'content': content
} }
response=requests.post(url=auto_reply_url, response = requests.post(url=auto_reply_url,
cookies=cookies_get, cookies=cookies_get,
data=post_dict) data=post_dict)
logging.info("response.text :%s"%(response.text)) logging.info("response.text :%s" % (response.text))
except: except:
logging.error("catch exception,reply:%s" % traceback.format_exc()) logging.error("catch exception,reply:%s" % traceback.format_exc())
def time_conv(numtime):
def time_conv(numtime):
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 return yes_time_str
except: except:
return None return None
def get_topic_id(numtime): def get_topic_id(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute("SELECT id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' " %numtime) cursor.execute(
"SELECT distinct(user_id),id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0) " % numtime)
data = cursor.fetchall() data = cursor.fetchall()
topic_id = list(data) topic_id = list(data)
logging.info("Database version : %s "%topic_id) logging.info("Database version : %s " % topic_id)
db.close() db.close()
return topic_id return topic_id
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 None
def get_comment(): def get_comment():
data = open("/srv/apps/cybertron/guanshui")
data = pd.read_csv("guanshui", sep='\n')
num = random.randint(0, len(data))
list_guanshui = [] list_guanshui = []
for i in data['comment scene']: for i in data:
l = i.split('\t') list_guanshui.append(i)
list_guanshui.append(l[0]) num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
comment = list_guanshui[num-1]
return comment return comment
if __name__ == "__main__": if __name__ == "__main__":
try: try:
time_list = [1,2,3,4,5,6,7] time_list = [1, 2, 3, 4, 5, 6, 7]
for i in time_list: for i in time_list:
...@@ -136,17 +133,34 @@ if __name__ == "__main__": ...@@ -136,17 +133,34 @@ if __name__ == "__main__":
topic_id = get_topic_id(numtime) topic_id = get_topic_id(numtime)
dicts = {}
for i in topic_id: for i in topic_id:
time.sleep(random.randint(10, 50)) if i[0] not in dicts.keys():
dicts.setdefault(i[0], [])
dicts[i[0]].append(i[1])
else:
dicts[i[0]].append(i[1])
print(dicts)
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 = logins() cook = logins()
if cook is not None: if cook is not None:
comment = get_comment() comment = get_comment()
reply(cook, i, comment) reply(cook, rand_id, comment)
except: except:
......
...@@ -7,25 +7,23 @@ import traceback ...@@ -7,25 +7,23 @@ import traceback
from log_settings import * from log_settings import *
import logging import logging
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
auto_pick_url = "http://earth.iyanzhi.com/api/v1/pick/do_pick" auto_pick_url = "http://earth.iyanzhi.com/api/v1/pick/do_pick"
def get_majia(): def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list=[] list = []
for i in data: for i in data:
list.append(i.strip('\n').strip(',')) list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list)) maj = random.randint(1, len(list))
user_id=list[maj-1] user_id = list[maj - 1]
return user_id return user_id
...@@ -33,10 +31,10 @@ def get_majia(): ...@@ -33,10 +31,10 @@ def get_majia():
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None return None
def get_cookies(user_id):
def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -49,21 +47,19 @@ def get_cookies(user_id): ...@@ -49,21 +47,19 @@ def get_cookies(user_id):
for i in list: for i in list:
if user_id == i[0]: if user_id == i[0]:
return (i[1]) return (i[1])
except: except:
return None return None
def logins():
def logins():
try: try:
user_id=get_majia() user_id = get_majia()
cookies = get_cookies(user_id) cookies = get_cookies(user_id)
if cookies is not None: if cookies is not None:
return {'sessionid': cookies} return {'sessionid': cookies}
except: except:
...@@ -72,8 +68,8 @@ def logins(): ...@@ -72,8 +68,8 @@ def logins():
return None return None
def follow(cookies_get, id):
def follow(cookies_get, id):
try: try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
...@@ -89,8 +85,8 @@ def follow(cookies_get, id): ...@@ -89,8 +85,8 @@ def follow(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
def time_conv(numtime):
try: try:
now = datetime.datetime.now() now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime) yes_time = now - datetime.timedelta(days=numtime)
...@@ -99,16 +95,19 @@ def time_conv(numtime): ...@@ -99,16 +95,19 @@ def time_conv(numtime):
except: except:
return None return None
def get_topic_new_user(numtime): def get_topic_new_user(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute("SELECT user_id FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute(
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
topic_data = cursor.fetchall() topic_data = cursor.fetchall()
cursor.execute("SELECT user_id FROM group_user_role WHERE create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute(
"SELECT distinct(user_id) FROM group_user_role WHERE create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
new_user_data = cursor.fetchall() new_user_data = cursor.fetchall()
topic_data = list(topic_data) topic_data = list(topic_data)
new_user_data = list(new_user_data) new_user_data = list(new_user_data)
...@@ -124,6 +123,7 @@ def get_topic_new_user(numtime): ...@@ -124,6 +123,7 @@ def get_topic_new_user(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
if __name__ == "__main__": if __name__ == "__main__":
try: try:
...@@ -131,29 +131,22 @@ if __name__ == "__main__": ...@@ -131,29 +131,22 @@ if __name__ == "__main__":
user_id = get_topic_new_user(numtime) user_id = get_topic_new_user(numtime)
for j in user_id: follow_num = random.randint(1, 2)
id = int(j[0]) for i in range(follow_num):
follow_num = random.randint(1,2) for j in user_id:
for i in range(follow_num): id = int(j[0])
time.sleep(random.randint(10, 50)) time.sleep(random.randint(10, 30))
cookies=logins() cookies = logins()
if cookies is not None: if cookies is not None:
follow(cookies, id) 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())
...@@ -11,7 +11,7 @@ auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" ...@@ -11,7 +11,7 @@ auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_majia(): def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list=[] list=[]
...@@ -31,7 +31,7 @@ def get_majia(): ...@@ -31,7 +31,7 @@ def get_majia():
def get_cookies(user_id): def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -95,11 +95,11 @@ def time_conv(numtime): ...@@ -95,11 +95,11 @@ def time_conv(numtime):
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute("SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%'" % numtime) cursor.execute("SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
...@@ -123,15 +123,15 @@ if __name__ == "__main__": ...@@ -123,15 +123,15 @@ if __name__ == "__main__":
user_id = get_data(numtime) user_id = get_data(numtime)
for j in user_id:
id = int(j[0])
follow_num = random.randint(1,2) follow_num = random.randint(1,2)
for i in range(follow_num): for i in range(follow_num):
time.sleep(random.randint(10, 50)) for j in user_id:
id = int(j[0])
time.sleep(random.randint(1,10))
cookies=logins() cookies=logins()
...@@ -139,6 +139,7 @@ if __name__ == "__main__": ...@@ -139,6 +139,7 @@ if __name__ == "__main__":
follow(cookies, id) 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())
......
...@@ -7,15 +7,15 @@ import pandas as pd ...@@ -7,15 +7,15 @@ import pandas as pd
import traceback import traceback
from log_settings import * from log_settings import *
import logging import logging
auto_click_url = "http://earth.iyanzhi.com/api/v1/like" auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create" auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_cookies(user_id): def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -28,7 +28,6 @@ def get_cookies(user_id): ...@@ -28,7 +28,6 @@ def get_cookies(user_id):
for i in list: for i in list:
if user_id == i[0]: if user_id == i[0]:
return (i[1]) return (i[1])
except: except:
...@@ -36,12 +35,10 @@ def get_cookies(user_id): ...@@ -36,12 +35,10 @@ def get_cookies(user_id):
def logins(user_id): def logins(user_id):
try: try:
cookies = get_cookies(user_id) cookies = get_cookies(user_id)
if cookies is not None: if cookies is not None:
return {'sessionid': cookies} return {'sessionid': cookies}
except: except:
...@@ -50,8 +47,8 @@ def logins(user_id): ...@@ -50,8 +47,8 @@ def logins(user_id):
return None return None
def follow(cookies_get, id):
def follow(cookies_get, id):
try: try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
...@@ -67,6 +64,7 @@ def follow(cookies_get, id): ...@@ -67,6 +64,7 @@ def follow(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(): def time_conv():
try: try:
now = datetime.datetime.now() now = datetime.datetime.now()
...@@ -75,15 +73,18 @@ def time_conv(): ...@@ -75,15 +73,18 @@ def time_conv():
except: except:
return None return None
def get_follw_majia(numtime): def get_follw_majia(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute("select temp1.user_id,temp1.email,temp2.user_id from account_user_auth temp1 left join (select user_id,follow_id,create_time from user_follow) temp2 on temp1.user_id = temp2.follow_id where temp1.email in ('s_05tmwu@shadow.com','s_07CRHt@shadow.com','s_0bdxxU@shadow.com','s_0mfxcO@shadow.com','s_0u6eaV@shadow.com','s_0UudEr@shadow.com','s_1b3v5V@shadow.com','s_ZVuLyC@shadow.com','s_1dbAoA@shadow.com','s_1dholX@shadow.com','s_1EpLlt@shadow.com') and temp2.create_time like '%%%%%s%%%%' "%(numtime)) cursor.execute(
"select temp1.user_id,temp1.email,temp2.user_id from account_user_auth temp1 left join (select user_id,follow_id,create_time from user_follow) temp2 on temp1.user_id = temp2.follow_id where temp1.email in ('s_05tmwu@shadow.com','s_07CRHt@shadow.com','s_0bdxxU@shadow.com','s_0mfxcO@shadow.com','s_0u6eaV@shadow.com','s_0UudEr@shadow.com','s_1b3v5V@shadow.com','s_ZVuLyC@shadow.com','s_1dbAoA@shadow.com','s_1dholX@shadow.com','s_1EpLlt@shadow.com') and temp2.create_time like '%%%%%s%%%%' " % (
numtime))
data = cursor.fetchall() data = cursor.fetchall()
data=list(data) data = list(data)
logging.info("Database version : %s " % data) logging.info("Database version : %s " % data)
db.close() db.close()
return data return data
...@@ -91,11 +92,12 @@ def get_follw_majia(numtime): ...@@ -91,11 +92,12 @@ def get_follw_majia(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
if __name__ == "__main__": if __name__ == "__main__":
try: try:
numtime=time_conv() numtime = time_conv()
# get majia zhanghao # get majia zhanghao
...@@ -137,22 +139,10 @@ if __name__ == "__main__": ...@@ -137,22 +139,10 @@ if __name__ == "__main__":
for i in value: for i in value:
cookies=logins(id) cookies = logins(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())
...@@ -6,21 +6,22 @@ import random ...@@ -6,21 +6,22 @@ import random
import traceback import traceback
from log_settings import * from log_settings import *
import logging import logging
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_majia():
def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list=[] list = []
for i in data: for i in data:
list.append(i.strip('\n').strip(',')) list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list)) maj = random.randint(1, len(list))
user_id=list[maj-1] user_id = list[maj - 1]
return user_id return user_id
...@@ -28,10 +29,10 @@ def get_majia(): ...@@ -28,10 +29,10 @@ def get_majia():
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None return None
def get_cookies(user_id):
def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -44,21 +45,19 @@ def get_cookies(user_id): ...@@ -44,21 +45,19 @@ def get_cookies(user_id):
for i in list: for i in list:
if user_id == i[0]: if user_id == i[0]:
return (i[1]) return (i[1])
except: except:
return None return None
def logins():
def logins():
try: try:
user_id=get_majia() user_id = get_majia()
cookies = get_cookies(user_id) cookies = get_cookies(user_id)
if cookies is not None: if cookies is not None:
return {'sessionid': cookies} return {'sessionid': cookies}
except: except:
...@@ -67,8 +66,8 @@ def logins(): ...@@ -67,8 +66,8 @@ def logins():
return None return None
def follow(cookies_get, id):
def follow(cookies_get, id):
try: try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
...@@ -84,6 +83,7 @@ def follow(cookies_get, id): ...@@ -84,6 +83,7 @@ def follow(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime): def time_conv(numtime):
try: try:
now = datetime.datetime.now() now = datetime.datetime.now()
...@@ -93,14 +93,15 @@ def time_conv(numtime): ...@@ -93,14 +93,15 @@ def time_conv(numtime):
except: except:
return None return None
def get_commnet_id(numtime): def get_commnet_id(numtime):
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT user_id FROM reply WHERE create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT user_id FROM reply WHERE create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data_comment = cursor.fetchall() data_comment = cursor.fetchall()
...@@ -116,24 +117,22 @@ def get_commnet_id(numtime): ...@@ -116,24 +117,22 @@ def get_commnet_id(numtime):
data_reply_reply = cursor.fetchall() data_reply_reply = cursor.fetchall()
cursor.execute( cursor.execute(
"SELECT user_id FROM group_user_role WHERE create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT user_id FROM group_user_role WHERE create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data_group_follow = cursor.fetchall() data_group_follow = cursor.fetchall()
cursor.execute( cursor.execute(
"select user_id from account_user WHERE create_time LIKE '%%%%%s%%%%'" % numtime) "select user_id from account_user WHERE create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data_new_user = cursor.fetchall() data_new_user = cursor.fetchall()
data_id = list(data_comment) data_id = list(data_comment)
data1_id=list(data_reply_topic) data1_id = list(data_reply_topic)
data2_id=list(data_group_follow) data2_id = list(data_group_follow)
data3_id=list(data_new_user) data3_id = list(data_new_user)
data_reply_reply = list(data_reply_reply) data_reply_reply = list(data_reply_reply)
user_id = [] user_id = []
...@@ -160,6 +159,7 @@ def get_commnet_id(numtime): ...@@ -160,6 +159,7 @@ def get_commnet_id(numtime):
return user_id return user_id
if __name__ == "__main__": if __name__ == "__main__":
try: try:
...@@ -181,27 +181,7 @@ if __name__ == "__main__": ...@@ -181,27 +181,7 @@ if __name__ == "__main__":
cookies = logins() cookies = logins()
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())
...@@ -12,7 +12,7 @@ auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" ...@@ -12,7 +12,7 @@ auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_majia(): def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list=[] list=[]
...@@ -32,7 +32,7 @@ def get_majia(): ...@@ -32,7 +32,7 @@ def get_majia():
def get_cookies(user_id): def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -95,9 +95,9 @@ def time_conv(numtime): ...@@ -95,9 +95,9 @@ def time_conv(numtime):
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work',passwd='oars152!traipseize738',db="alpha", port=3306) db = pymysql.connect(host="172.17.40.144", user='work',passwd='oars152!traipseize738',db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute("select user_id from account_user_auth where user_id not in (select user_id from pv_maidian where page_name ='home' and partiton_date >= %s )" ,(numtime)) cursor.execute("select user_id from account_user_auth where user_id not in (select user_id from pv_maidian where page_name ='home' and partiton_date >= %s ) and user_id in (select user_id from user_extra where is_shadow = 0)" ,(numtime))
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
...@@ -113,15 +113,15 @@ if __name__ == "__main__": ...@@ -113,15 +113,15 @@ if __name__ == "__main__":
user_id = get_data(numtime) user_id = get_data(numtime)
for i in user_id:
urge_num = random.randint(1,2) urge_num = random.randint(1,2)
for j in range(urge_num): for j in range(urge_num):
cookies = index_first() for i in user_id:
cookies = get_cookies(i)
time.sleep(random.randint(10, 50)) time.sleep(random.randint(1, 10))
cook=logins() cook=logins()
...@@ -129,7 +129,7 @@ if __name__ == "__main__": ...@@ -129,7 +129,7 @@ if __name__ == "__main__":
follow(cook, i) follow(cook, i)
time.sleep(300)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -137,9 +137,3 @@ if __name__ == "__main__": ...@@ -137,9 +137,3 @@ if __name__ == "__main__":
...@@ -7,24 +7,21 @@ import traceback ...@@ -7,24 +7,21 @@ import traceback
from log_settings import * from log_settings import *
import logging import logging
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_majia(): def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list=[] list = []
for i in data: for i in data:
list.append(i.strip('\n').strip(',')) list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list)) maj = random.randint(1, len(list))
user_id=list[maj-1] user_id = list[maj - 1]
return user_id return user_id
...@@ -32,10 +29,10 @@ def get_majia(): ...@@ -32,10 +29,10 @@ def get_majia():
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None return None
def get_cookies(user_id):
def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -48,21 +45,19 @@ def get_cookies(user_id): ...@@ -48,21 +45,19 @@ def get_cookies(user_id):
for i in list: for i in list:
if user_id == i[0]: if user_id == i[0]:
return (i[1]) return (i[1])
except: except:
return None return None
def logins():
def logins():
try: try:
user_id=get_majia() user_id = get_majia()
cookies = get_cookies(user_id) cookies = get_cookies(user_id)
if cookies is not None: if cookies is not None:
return {'sessionid': cookies} return {'sessionid': cookies}
except: except:
...@@ -71,6 +66,7 @@ def logins(): ...@@ -71,6 +66,7 @@ def logins():
return None return None
def follow(cookies_get, id): def follow(cookies_get, id):
try: try:
post_dict = { post_dict = {
...@@ -87,6 +83,7 @@ def follow(cookies_get, id): ...@@ -87,6 +83,7 @@ def follow(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime): def time_conv(numtime):
try: try:
now = datetime.datetime.now() now = datetime.datetime.now()
...@@ -96,13 +93,15 @@ def time_conv(numtime): ...@@ -96,13 +93,15 @@ def time_conv(numtime):
except: except:
return None return None
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute("select user_id from pv_maidian where page_name ='home' and partiton_date like '%%%%%s%%%%' " % numtime) cursor.execute(
"select user_id from pv_maidian where page_name ='home' and partiton_date like '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
...@@ -112,30 +111,24 @@ def get_data(numtime): ...@@ -112,30 +111,24 @@ def get_data(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
if __name__ == "__main__": if __name__ == "__main__":
try: try:
numtime = time_conv(1) numtime = time_conv(1)
user_id = get_data(numtime) user_id = get_data(numtime)
urge_num = random.randint(0, 1)
for j in range(urge_num):
for i in user_id: for i in user_id:
id = int(i[0]) id = int(i[0])
urge_num = random.randint(0, 1) time.sleep(random.randint(1, 10))
for i in range(urge_num):
time.sleep(random.randint(10, 50)) cook = logins()
cook=logins()
if cook is not None: if cook is not None:
follow(cook, id)
follow(cook,id) time.sleep(300)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -11,19 +11,19 @@ auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow" ...@@ -11,19 +11,19 @@ auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
auto_click_url = "http://earth.iyanzhi.com/api/v1/like" auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
def get_majia():
def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list=[] list = []
for i in data: for i in data:
list.append(i.strip('\n').strip(',')) list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list)) maj = random.randint(1, len(list))
user_id=list[maj-1] user_id = list[maj - 1]
return user_id return user_id
...@@ -31,10 +31,10 @@ def get_majia(): ...@@ -31,10 +31,10 @@ def get_majia():
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None return None
def get_cookies(user_id):
def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -47,21 +47,19 @@ def get_cookies(user_id): ...@@ -47,21 +47,19 @@ def get_cookies(user_id):
for i in list: for i in list:
if user_id == i[0]: if user_id == i[0]:
return (i[1]) return (i[1])
except: except:
return None return None
def logins():
def logins():
try: try:
user_id=get_majia() user_id = get_majia()
cookies = get_cookies(user_id) cookies = get_cookies(user_id)
if cookies is not None: if cookies is not None:
return {'sessionid': cookies} return {'sessionid': cookies}
except: except:
...@@ -70,8 +68,8 @@ def logins(): ...@@ -70,8 +68,8 @@ def logins():
return None return None
def click(cookies_get, id):
def click(cookies_get, id):
try: try:
post_dict = { post_dict = {
'type': 0, 'type': 0,
...@@ -87,8 +85,8 @@ def click(cookies_get, id): ...@@ -87,8 +85,8 @@ def click(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def follow(cookies_get, id):
def follow(cookies_get, id):
try: try:
post_dict = { post_dict = {
'type': 1, 'type': 1,
...@@ -106,8 +104,8 @@ def follow(cookies_get, id): ...@@ -106,8 +104,8 @@ def follow(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
def time_conv(numtime):
try: try:
now = datetime.datetime.now() now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime) yes_time = now - datetime.timedelta(days=numtime)
...@@ -116,14 +114,15 @@ def time_conv(numtime): ...@@ -116,14 +114,15 @@ def time_conv(numtime):
except: except:
return None return None
def get_star_user_id(numtime): def get_star_user_id(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT user_id FROM topic WHERE is_online=1 and content_level =4 or content_level =5 and create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT user_id FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
...@@ -133,14 +132,15 @@ def get_star_user_id(numtime): ...@@ -133,14 +132,15 @@ def get_star_user_id(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
def get_star_topic_id(numtime): def get_star_topic_id(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT id FROM topic WHERE is_online=1 and content_level =4 or content_level =5 and create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT id FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
...@@ -150,11 +150,11 @@ def get_star_topic_id(numtime): ...@@ -150,11 +150,11 @@ def get_star_topic_id(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
if __name__ == "__main__":
if __name__ == "__main__":
try: try:
time_list = [1,2,3,4,5,6,7] time_list = [1, 2, 3, 4, 5, 6, 7]
for i in time_list: for i in time_list:
...@@ -162,21 +162,24 @@ if __name__ == "__main__": ...@@ -162,21 +162,24 @@ if __name__ == "__main__":
user_id = get_star_topic_id(numtime) user_id = get_star_topic_id(numtime)
for j in user_id:
id = int(j[0])
urge_num = random.randint(0, 1) urge_num = random.randint(0, 1)
for i in range(urge_num): for i in range(urge_num):
for j in user_id:
time.sleep(random.randint(10, 50)) id = int(j[0])
time.sleep(random.randint(1, 10))
cookies = logins() cookies = logins()
if cookies is not None: if cookies is not None:
click(cookies, id) click(cookies, id)
time.sleep(300)
urge_num = random.randint(1, 2)
for i in range(urge_num):
user_id = get_star_user_id(numtime) user_id = get_star_user_id(numtime)
...@@ -184,11 +187,7 @@ if __name__ == "__main__": ...@@ -184,11 +187,7 @@ if __name__ == "__main__":
id = int(j[0]) id = int(j[0])
urge_num = random.randint(1, 2) time.sleep(random.randint(1, 10))
for i in range(urge_num):
time.sleep(random.randint(10, 50))
cookies = logins() cookies = logins()
...@@ -197,5 +196,3 @@ if __name__ == "__main__": ...@@ -197,5 +196,3 @@ if __name__ == "__main__":
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
...@@ -12,7 +12,7 @@ auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge" ...@@ -12,7 +12,7 @@ auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
def get_majia(): def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list=[] list=[]
...@@ -33,7 +33,7 @@ def get_majia(): ...@@ -33,7 +33,7 @@ def get_majia():
def get_cookies(user_id): def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -52,6 +52,7 @@ def get_cookies(user_id): ...@@ -52,6 +52,7 @@ def get_cookies(user_id):
return None return None
def logins(): def logins():
try: try:
...@@ -98,12 +99,12 @@ def time_conv(numtime): ...@@ -98,12 +99,12 @@ def time_conv(numtime):
def get_star_useid(numtime): def get_star_useid(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute( cursor.execute(
"SELECT user_id FROM topic WHERE is_online=1 and content_level =4 or content_level =5 and create_time LIKE '%%%%%s%%%%'" % numtime) "SELECT user_id FROM topic WHERE is_online=1 and (content_level =4 or content_level =5) and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
......
...@@ -12,7 +12,7 @@ auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge" ...@@ -12,7 +12,7 @@ auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
def get_majia(): def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list=[] list=[]
...@@ -32,7 +32,7 @@ def get_majia(): ...@@ -32,7 +32,7 @@ def get_majia():
def get_cookies(user_id): def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -51,6 +51,7 @@ def get_cookies(user_id): ...@@ -51,6 +51,7 @@ def get_cookies(user_id):
return None return None
def logins(): def logins():
try: try:
...@@ -94,41 +95,25 @@ def time_conv(numtime): ...@@ -94,41 +95,25 @@ def time_conv(numtime):
except: except:
return None return None
def get_data(numtime):
try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute("SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_star_useid(numtime):
def get_data(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute( cursor.execute("SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time LIKE '%%%%%s%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
"SELECT user_id FROM topic WHERE is_online=1 and content_level =4 or content_level =5 and create_time LIKE '%%%%%s%%%%'" % numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
db.close() db.close()
return user_id return user_id
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 None
if __name__ == "__main__": if __name__ == "__main__":
try: try:
...@@ -140,42 +125,22 @@ if __name__ == "__main__": ...@@ -140,42 +125,22 @@ if __name__ == "__main__":
user_id = get_data(numtime) user_id = get_data(numtime)
for j in user_id:
id = int(j[0])
urge_num = random.randint(0, 2) urge_num = random.randint(0, 2)
for i in range(urge_num): for i in range(urge_num):
time.sleep(random.randint(10, 50))
cookies=logins()
if cookies is not None:
Urge(cookies, id)
for i in time_list:
numtime = time_conv(i)
user_id = get_star_useid(numtime)
for j in user_id: for j in user_id:
id = int(j[0]) id = int(j[0])
for i in range(1): time.sleep(random.randint(3, 10))
time.sleep(random.randint(10, 50)) cookies=logins()
cookies = logins()
if cookies is not None: if cookies is not None:
Urge(cookies, id) Urge(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())
...@@ -9,19 +9,19 @@ import logging ...@@ -9,19 +9,19 @@ import logging
auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge" auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
def get_majia():
def get_majia():
try: try:
data = open("batch_user_gen") data = open("/srv/apps/cybertron/batch_user_gen")
list=[] list = []
for i in data: for i in data:
list.append(i.strip('\n').strip(',')) list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list)) maj = random.randint(1, len(list))
user_id=list[maj-1] user_id = list[maj - 1]
return user_id return user_id
...@@ -29,10 +29,10 @@ def get_majia(): ...@@ -29,10 +29,10 @@ def get_majia():
logging.error("catch exception,get_majia:%s" % traceback.format_exc()) logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None return None
def get_cookies(user_id):
def get_cookies(user_id):
try: try:
with open("user_session.txt", 'r') as f: with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try: try:
data = f.readlines() data = f.readlines()
except: except:
...@@ -45,21 +45,19 @@ def get_cookies(user_id): ...@@ -45,21 +45,19 @@ def get_cookies(user_id):
for i in list: for i in list:
if user_id == i[0]: if user_id == i[0]:
return (i[1]) return (i[1])
except: except:
return None return None
def logins():
def logins():
try: try:
user_id=get_majia() user_id = get_majia()
cookies = get_cookies(user_id) cookies = get_cookies(user_id)
if cookies is not None: if cookies is not None:
return {'sessionid': cookies} return {'sessionid': cookies}
except: except:
...@@ -68,8 +66,8 @@ def logins(): ...@@ -68,8 +66,8 @@ def logins():
return None return None
def Urge(cookies_get, id):
def Urge(cookies_get, id):
try: try:
post_dict = { post_dict = {
'id': id 'id': id
...@@ -84,6 +82,7 @@ def Urge(cookies_get, id): ...@@ -84,6 +82,7 @@ def Urge(cookies_get, id):
logging.error("catch exception,logins:%s" % traceback.format_exc()) logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime): def time_conv(numtime):
try: try:
now = datetime.datetime.now() now = datetime.datetime.now()
...@@ -93,13 +92,16 @@ def time_conv(numtime): ...@@ -93,13 +92,16 @@ def time_conv(numtime):
except: except:
return None return None
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="rm-2zej7rzxnj036zxt3.mysql.rds.aliyuncs.com", user='work', db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738', passwd='oars152!traipseize738',
db="alpha", port=3306) db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute("select user_id from account_user_auth where user_id not in (select user_id from pv_maidian where page_name ='home' and partiton_date >= %s) ", (numtime)) cursor.execute(
"select user_id from account_user_auth where user_id not in (select user_id from pv_maidian where page_name ='home' and partiton_date >= %s) and user_id in (select user_id from user_extra where is_shadow = 0)",
(numtime))
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % user_id) logging.info("Database version : %s " % user_id)
...@@ -109,6 +111,7 @@ def get_data(numtime): ...@@ -109,6 +111,7 @@ def get_data(numtime):
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
if __name__ == "__main__": if __name__ == "__main__":
try: try:
...@@ -116,29 +119,18 @@ if __name__ == "__main__": ...@@ -116,29 +119,18 @@ if __name__ == "__main__":
user_id = get_data(numtime) user_id = get_data(numtime)
for i in user_id: for j in range(2):
urge_num = random.randint(1, 2) for i in user_id:
for j in range(urge_num):
time.sleep(random.randint(1, 15)) time.sleep(random.randint(1, 15))
cook = logins() cook = logins()
if cook is not None: if cook is not None:
Urge(cook, i) Urge(cook, i)
time.sleep(300)
except: except:
logging.error("catch exception,main:%s" % traceback.format_exc()) logging.error("catch exception,main:%s" % traceback.format_exc())
This diff is collapsed.
import requests import requests
import time
import datetime
import pymysql
import random
import traceback import traceback
# from log_settings import *
import logging import logging
import json
login_url = "http://earth.iyanzhi.com/api/account/login_pwd" login_url = "http://earth.iyanzhi.com/api/account/login_pwd"
def index_first(): def index_first():
try: try:
r1 = requests.get(login_url) r1 = requests.get(login_url)
...@@ -22,56 +17,40 @@ def index_first(): ...@@ -22,56 +17,40 @@ def index_first():
def get_cook(): def get_cook():
data = open("batch_user_gen") data = open("batch_user_gen")
list=[] list = []
dict={} dicts = {}
for i in data: for i in data:
list.append(i.strip('\n').strip(',')) list.append(i.strip('\n').strip(','))
for i in list: for i in list:
cookies = index_first() cookies = index_first()
post_dict={ post_dict = {
'account_type':2, 'account_type': 2,
'pwd':'123456', 'pwd': '123456',
'email':i 'email': i
} }
response = requests.post( response = requests.post(
url=login_url, url=login_url,
data=post_dict, data=post_dict,
cookies=cookies cookies=cookies
) )
headers=response.headers headers = response.headers
print(response.text) print(response.text)
cook = headers['Set-Cookie'].split(";") cook = headers['Set-Cookie'].split(";")
cook = cook[0].split('=')[1] cook = cook[0].split('=')[1]
logging.info("response.text :%s" % response.text) logging.info("response.text :%s" % response.text)
dict[i] = cook dicts[i] = cook
return dict
dict=get_cook() return dicts
with open("user_session.txt" ,'w') as f: dicts = get_cook()
for key,value in dict.items():
with open("user_session.txt", 'w') as f:
for key, value in dicts.items():
f.write(key) f.write(key)
f.write(",") f.write(",")
f.write(value) f.write(value)
f.write("\n") f.write("\n")
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