Commit e12124b3 authored by lixiaofang's avatar lixiaofang

add

parents c180e54d 4f2858a8
<?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$/comment_data" charset="GBK" />
<file url="file://$PROJECT_DIR$/comment_data.csv" 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
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (code)" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
import requests
import time
import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def login():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id):
try:
post_dict = {
'type': 0,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def reply(cookies_get, id, content):
try:
post_dict = {
'topic_id': id,
'content': content
}
response = requests.post(url=auto_reply_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv():
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=15)
print(yes_time)
return yes_time
except:
return None
def get_topic_id(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work', passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
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()
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_comment():
try:
data = open("/srv/apps/cybertron/guanshui", "r")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
return comment
except:
return None
if __name__ == "__main__":
try:
numtime = time_conv()
topic_id = get_topic_id(numtime)
click_num = random.randint(1, 3)
for i in range(click_num):
for j in topic_id:
id = int(j[0])
cookies = login()
time.sleep(random.randint(1, 10))
click(cookies, id)
time.sleep(300)
topic_id = get_topic_id(numtime)
comment_num = random.randint(1, 3)
for i in range(comment_num):
for j in topic_id:
id = int(j[0])
cookies = login()
if cookies is not None:
comment = get_comment()
time.sleep(random.randint(1, 10))
reply(cookies, id, comment)
time.sleep(300)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
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
auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def login():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id):
try:
post_dict = {
'type': 0,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_data(numtime):
def get_data(numtime, numtime2):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
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)
"SELECT user_id,id FROM topic WHERE is_online=1 and create_time > '%s' and create_time <= '%s'" % (
numtime, numtime2))
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
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 None
return []
if __name__ == "__main__":
......@@ -119,38 +41,38 @@ if __name__ == "__main__":
time_list = [1, 2, 3, 4, 5, 6, 7]
for i in time_list:
numtime = time_conv(i)
user_id = get_data(numtime)
numtime, numtime2 = time_convs(i + 1, i - 1)
user_id = get_data(numtime, numtime2)
dicts = {}
for i in user_id:
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])
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():
else:
dicts[i[0]].append(i[1])
rand_num = random.randint(0, len(value) - 1)
for key, value in dicts.items():
rand_num = random.randint(0, len(value) - 1)
rand_id = value[rand_num]
rand_id = value[rand_num]
urge_num = random.randint(0, 1)
urge_num = random.randint(0, 1)
for i in range(urge_num):
for i in range(urge_num):
time.sleep(random.randint(1, 10))
time.sleep(random.randint(1, 10))
cook = login()
cook = login()
if cook is not None:
click(cook, rand_id)
if cook is not None:
click(cook, rand_id)
else:
pass
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:
numtime, numtime2 = time_conv(5,0)
user_id = get_data(numtime, numtime2)
dicts = {}
for i in user_id:
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:
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())
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 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())
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()
cursor.execute(
"select id from topic where content_level in (4,5,6) and create_time > '2019-05-01 00:00:00.0000' and id not in (select topic_id from reply )")
data = cursor.fetchall()
topic_id = list(data)
pc.close()
return topic_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
if __name__ == "__main__":
try:
numtime, numtime2 = time_conv(15, 5)
user_id = get_data(numtime, numtime2)
dicts = {}
logging.info("get user_id:%s" % user_id)
for i in user_id:
cook = login()
if cook is not None:
click(cook, i)
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()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '2019-05-01 00:00:00.000000' and create_time <= '2019-05-13 00:00:00.000000')")
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
try:
for i in topic_id:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute("select topic_id from reply where topic_id =" + str(i[1]))
data_s = cursor.fetchall()
topic_id_s = list(data_s)
if len(topic_id_s) == 0:
try:
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 []
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
if __name__ == "__main__":
try:
numtime, numtime2 = time_conv(15, 5)
user_id = get_data(numtime, numtime2)
dicts = {}
for i in user_id:
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):
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" % (numtime))
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:
numtime = time_conv(15)
user_id = get_data(numtime)
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]
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)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
import pymysql
import random
import traceback
import logging
auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id):
try:
post_dict = {
'type': 0,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_data(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
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()
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
if __name__ == "__main__":
try:
time_list = [1, 2, 3, 4, 5, 6, 7]
for i in time_list:
numtime = time_conv(7 + 3 * i)
user_id = get_data(numtime)
dict = {}
for i in user_id:
if i[0] not in dict.keys():
dict.setdefault(i[0], [])
dict[i[0]].append(i[1])
else:
dict[i[0]].append(i[1])
for key, value in dict.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 = logins()
if cook is not None:
click(cook, rand_id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
import pymysql
import random
import traceback
import logging
from log_settings import *
from auto_request import login, time_convs, reply, get_comment
from auto_request import host, user, db, passwd
def get_topic_id(numtime1, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT id,user_id FROM topic WHERE is_online=1 and create_time > '%s' and create_time < '%s' " % (
numtime1, numtime2)
)
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
if topic_id:
for i in topic_id:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[1]) + " and is_shadow =0 ")
data = cursor.fetchall()
user_id = list(data)
if user_id:
topic_id_list.append(i)
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:
numtime1, numtime2 = time_convs(i + 1, i - 1)
topic_id = get_topic_id(numtime1, numtime2)
dicts = {}
try:
for i in topic_id and topic_id:
if i[1] not in dicts.keys():
dicts.setdefault(i[1], [])
dicts[i[1]].append(i[0])
else:
dicts[i[1]].append(i[0])
except:
pass
for key, value in dicts.items():
rand_num = random.randint(0, len(value) - 1)
rand_id = value[rand_num]
comment = get_comment()
for i in range(1):
time.sleep(random.randint(10, 20))
cook = login()
if cook is not None:
reply(cook, rand_id, comment)
except:
logging.error("catch exception,main :%s" % traceback.format_exc())
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_conv, get_comment, reply
from auto_request import host, user, db, passwd
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
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
if __name__ == "__main__":
try:
logging.info("comment one")
numtime1, numtime2 = time_conv(5, 0)
user_id = get_data(numtime1, numtime2)
dicts = {}
if user_id:
for i in user_id:
cook = login()
comment = get_comment()
if cook is not None:
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())
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_conv, get_comment, reply
from auto_request import host, user, db, passwd
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 >= '2019-05-09 00:00:00.000000' and create_time <= '2019-05-13 00:00:00.000000')")
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
try:
for i in topic_id:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute("select topic_id from reply where topic_id =" + str(i[1]))
data_s = cursor.fetchall()
topic_id_s = list(data_s)
if len(topic_id_s) == 0:
try:
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 []
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
if __name__ == "__main__":
try:
logging.info("comment one")
numtime1, numtime2 = time_conv(15, 5)
user_id = get_data(numtime1, numtime2)
dicts = {}
if user_id:
for i in user_id:
cook = login()
comment = get_comment()
if cook is not None:
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())
import time
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_conv, get_comment, reply
from auto_request import host, user, db, passwd
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
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
if __name__ == "__main__":
try:
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[1], comment)
else:
logging.error("catch exception,main:%s" % traceback.format_exc())
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, time_conv, get_comment, reply
from auto_request import host, user, db, passwd
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
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
if __name__ == "__main__":
try:
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()
if cook is not None:
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())
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
from auto_request import login, time_conv, get_comment, reply
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 >= '2019-05-01 00:00:00.000000' and create_time <= '2019-05-14 00:00:00.000000') and id not in (select topic_id from reply where create_time > '2019-05-01 00:00:00.000000')")
data = cursor.fetchall()
topic_id = list(data)
pc.close()
return topic_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
if __name__ == "__main__":
try:
logging.info("comment one")
numtime1, numtime2 = time_conv(5, 0)
user_id = get_data(numtime1, numtime2)
dicts = {}
if user_id:
for i in user_id:
cook = login()
comment = get_comment()
if cook is not None:
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())
import requests
import time
import datetime
import pymysql
import random
import traceback
import logging
auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen.txt")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def reply(cookies_get, id, content):
try:
post_dict = {
'topic_id': id,
'content': content
}
response = requests.post(url=auto_reply_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text :%s" % (response.text))
except:
logging.error("catch exception,reply:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_topic_id(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
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()
topic_id = list(data)
logging.info("Database version : %s " % topic_id)
db.close()
return topic_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def get_comment():
data = open("/srv/apps/cybertron/guanshui")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
return comment
if __name__ == "__main__":
try:
time_list = [1, 2, 3, 4, 5, 6, 7]
for i in time_list:
numtime = time_conv(i)
topic_id = get_topic_id(numtime)
dicts = {}
for i in topic_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])
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()
if cook is not None:
comment = get_comment()
reply(cook, rand_id, comment)
except:
logging.error("catch exception,main :%s" % traceback.format_exc())
......@@ -6,147 +6,76 @@ import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_convs, follow, get_user_id
from auto_request import host, user, port, db, passwd
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
auto_pick_url = "http://earth.iyanzhi.com/api/v1/pick/do_pick"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
def get_topic_new_user(numtime1, numtime2):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_topic_new_user(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
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 distinct(user_id) FROM topic WHERE is_online=1 and create_time > '%s' " % numtime1)
topic_data = cursor.fetchall()
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)
"SELECT distinct(user_id) FROM group_user_role WHERE create_time > '%s'" % numtime1)
new_user_data = cursor.fetchall()
topic_data = list(topic_data)
new_user_data = list(new_user_data)
user_id = []
for i in topic_data:
user_id.append(i)
for i in new_user_data:
user_id.append(i)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
topic_id_list = []
if topic_data:
for i in topic_data:
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)
if new_user_data:
for i in new_user_data:
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 None
return []
if __name__ == "__main__":
try:
numtime = time_conv(0)
numtime1, numtime2 = time_convs(1, 1)
user_id = get_topic_new_user(numtime)
user_id = get_topic_new_user(numtime1, numtime2)
follow_num = random.randint(1, 2)
for i in range(follow_num):
for j in user_id:
try:
id = int(j[0])
for j in user_id and user_id:
time.sleep(random.randint(10, 30))
id = int(j[0])
cookies = logins()
time.sleep(random.randint(10, 30))
if cookies is not None:
follow(cookies, id)
cookies = login()
time.sleep(300)
if cookies is not None:
follow(cookies, id)
except:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -6,141 +6,55 @@ import random
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
from auto_request import login, time_convs, follow
from auto_request import host, user, port, db, passwd
def get_majia():
def get_data(numtime1, numtime2):
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list))
user_id=list[maj-1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id=get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_data(numtime):
try:
db = pymysql.connect(host="172.17.40.144", 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%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % numtime)
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time > '%s' and create_time < '%s'" % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
topic_id_list = []
if user_id:
for i in user_id:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
data = cursor.fetchall()
id = list(data)
if 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 None
return []
if __name__ == "__main__":
try:
time_list = [1,2,3,4,5,6,7,11]
for i in range(len(time_list)):
if time_list[i] != 11:
numtime = time_conv(time_list[i])
time_list = [1, 2, 3, 4, 5, 6, 7]
user_id = get_data(numtime)
numtime1, numtime2 = time_convs(8, 0)
follow_num = random.randint(1,2)
user_id = get_data(numtime1, numtime2)
for i in range(follow_num):
for j in user_id and user_id:
for j in user_id:
id = int(j[0])
id = int(j[0])
cookies = login()
time.sleep(random.randint(1,10))
if cookies is not None:
follow(cookies, id)
cookies=logins()
if cookies is not None:
follow(cookies, id)
time.sleep(300)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_convs, follow
from auto_request import host, user, port, db, passwd
def get_data(numtime1, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time > '%s' and create_time < '%s'" % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
topic_id_list = []
if user_id:
for i in user_id:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0")
data = cursor.fetchall()
id = list(data)
if 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]
numtime1, numtime2 = time_convs(8, 0)
user_id = get_data(numtime1, numtime2)
for j in user_id and user_id:
follow_num = random.randint(0, 1)
if follow_num == 1:
id = int(j[0])
cookies = login()
if cookies is not None:
follow(cookies, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -7,142 +7,82 @@ import pandas as pd
import traceback
from log_settings import *
import logging
from auto_request import login, time_conv, follow
from auto_request import host, user, port, db, passwd
auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins(user_id):
try:
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv():
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=15)
return yes_time
except:
return None
##做不了
def get_follw_majia(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.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))
data = cursor.fetchall()
data = list(data)
logging.info("Database version : %s " % data)
db.close()
pc.close()
return data
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
return []
if __name__ == "__main__":
try:
numtime = time_conv()
# get majia zhanghao
numtime = time_conv(15)
data = get_follw_majia(numtime)
dict_follow_id = {}
for j in data:
if data:
for j in data:
if j[2] != None:
if j[2] != None:
if j[0] not in dict_follow_id.keys():
if j[0] not in dict_follow_id.keys():
dict_follow_id.setdefault(j[0], [])
dict_follow_id.setdefault(j[0], [])
dict_follow_id[j[0]].append(j[2])
dict_follow_id[j[0]].append(j[2])
else:
dict_follow_id[j[0]].append(j[2])
else:
dict_follow_id[j[0]].append(j[2])
dict_email = {}
for j in data:
try:
if j[2] != None:
for j in data and data:
if j[0] not in dict_email.keys():
if j[2] != None:
dict_email.setdefault(j[0], [])
if j[0] not in dict_email.keys():
dict_email[j[0]].append(j[1])
dict_email.setdefault(j[0], [])
else:
dict_email[j[0]].append(j[1])
dict_email[j[0]].append(j[1])
for key, value in dict_follow_id.items():
else:
dict_email[j[0]].append(j[1])
id = dict_email[key][0]
for key, value in dict_follow_id.items():
for i in value:
id = dict_email[key][0]
cookies = logins(id)
for i in value:
if cookies is not None:
follow(cookies, i)
cookies = login(id)
if cookies is not None:
follow(cookies, i)
except:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -6,126 +6,40 @@ import random
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
from auto_request import login, time_convs, follow
from auto_request import host, user, port, db, passwd
def get_commnet_id(numtime):
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"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)
"SELECT user_id FROM reply WHERE create_time > '%s' " % numtime)
data_comment = cursor.fetchall()
cursor.execute(
"SELECT t.user_id from topic t left join reply r on r.topic_id = t.id WHERE r.create_time LIKE '%%%%%s%%%%'" % numtime)
"SELECT t.user_id from topic t left join reply r on r.topic_id = t.id WHERE r.create_time > '%s'" % numtime)
data_reply_topic = cursor.fetchall()
cursor.execute(
"SELECT r.user_id from reply r left join reply p on r.replied_id = p.replied_id WHERE p.create_time LIKE '%%%%%s%%%%'" % numtime)
"SELECT r.user_id from reply r left join reply p on r.replied_id = p.replied_id WHERE p.create_time > '%s'" % numtime)
data_reply_reply = cursor.fetchall()
cursor.execute(
"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)
"SELECT user_id FROM group_user_role WHERE create_time > '%s' " % numtime)
data_group_follow = cursor.fetchall()
cursor.execute(
"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)
"select user_id from account_user WHERE create_time > '%s'" % numtime)
data_new_user = cursor.fetchall()
......@@ -133,55 +47,82 @@ def get_commnet_id(numtime):
data1_id = list(data_reply_topic)
data2_id = list(data_group_follow)
data3_id = list(data_new_user)
data_reply_reply = list(data_reply_reply)
user_id = []
for i in data_id:
if i[0] is not None:
user_id.append(i)
for i in data1_id:
if i[0] is not None:
user_id.append(i)
for i in data2_id:
if i[0] is not None:
user_id.append(i)
for i in data3_id:
if i[0] is not None:
user_id.append(i)
for i in data_reply_reply:
if i[0] is not None:
user_id.append(i)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
data_reply = list(data_reply_reply)
topic_id_list = []
for i in data_id and data_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)
for i in data1_id and data1_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)
for i in data2_id and data2_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)
for i in data3_id and data3_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)
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)
logging.info("Database version : %s " % topic_id_list)
pc.close()
return topic_id_list
if __name__ == "__main__":
try:
numtime = time_conv(1)
numtime1, numtime2 = time_convs(1, 2)
user_id = get_commnet_id(numtime1)
user_id = get_commnet_id(numtime)
try:
for j in user_id:
for j in user_id and user_id:
id = int(j[0])
id = int(j[0])
follow_num = random.randint(0, 1)
follow_num = random.randint(0, 1)
for i in range(follow_num):
for i in range(follow_num):
time.sleep(random.randint(10, 50))
time.sleep(random.randint(10, 50))
cookies = logins()
cookies = login()
if cookies is not None:
follow(cookies, id)
if cookies is not None:
follow(cookies, id)
except:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -6,134 +6,40 @@ import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_conv, follow, get_cookies, time_now
from auto_request import host, user, db, passwd
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list))
user_id=list[maj-1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id=get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
def get_data(numtime1, numtime2):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_data(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',passwd='oars152!traipseize738',db="alpha", port=3306)
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 ) and user_id in (select user_id from user_extra where is_shadow = 0)" ,(numtime))
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"select distinct(user_id) from topic where is_online=1 and create_time > '%s' and create_time < '%s' and is_shadow = 0" % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
numtime = time_conv(3)
user_id = get_data(numtime)
urge_num = random.randint(1,2)
for j in range(urge_num):
for i in user_id:
numtime1, numtime2 = time_now(10)
cookies = get_cookies(i)
user_id = get_data(numtime1, numtime2)
time.sleep(random.randint(1, 10))
for i in user_id and user_id:
cook=logins()
cookies = get_cookies(i)
if cook is not None:
follow(cook, i)
time.sleep(300)
cook = login()
if cook is not None:
follow(cook, i)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_conv, follow, get_cookies, time_now
from auto_request import host, user, db, passwd
def get_data(numtime1, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"select distinct(user_id) from topic where is_online=1 and create_time > '%s' and create_time < '%s' and is_shadow = 0" % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
numtime1, numtime2 = time_now(10)
user_id = get_data(numtime1, numtime2)
for i in user_id and user_id:
num = random.randint(0, 1)
if num == 1:
cookies = get_cookies(i)
cook = login()
if cook is not None:
follow(cook, i)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -6,106 +6,32 @@ import random
import traceback
from log_settings import *
import logging
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
from auto_request import login, time_convs, follow, Urge
from auto_request import host, user, db, passwd
def get_data(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db="physical", port=3306)
cursor = pc.cursor()
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)
"select user_id from sl_user_login_status where last_visit_day < '%s' and is_shadow =0 " % numtime)
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
# topic_id_list = []
# for i in user_id and user_id:
# pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
# cursor = pc.cursor()
# 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 user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
......@@ -114,21 +40,12 @@ def get_data(numtime):
if __name__ == "__main__":
try:
numtime = time_conv(1)
user_id = get_data(numtime)
urge_num = random.randint(0, 1)
for j in range(urge_num):
for i in user_id:
id = int(i[0])
time.sleep(random.randint(1, 10))
cook = logins()
if cook is not None:
follow(cook, id)
time.sleep(300)
numtime1, numtime2 = time_convs(1, 3)
user_id = get_data(numtime2)
for i in user_id:
id = int(i[0])
cook = login()
if cook is not None:
Urge(cook, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_convs, follow, Urge
from auto_request import host, user, db, passwd
def get_data(numtime):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db="physical", port=3306)
cursor = pc.cursor()
cursor.execute(
"select user_id from sl_user_login_status where last_visit_day < '%s' and is_shadow = 0 " % numtime)
data = cursor.fetchall()
user_id = list(data)
# topic_id_list = []
# for i in user_id and user_id:
# pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
# cursor = pc.cursor()
# 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 " % user_id)
pc.close()
return user_id
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
if __name__ == "__main__":
try:
numtime1, numtime2 = time_convs(1, 3)
user_id = get_data(numtime2)
for i in user_id and user_id:
num = random.randint(0, 1)
if num == 1:
id = int(i[0])
cook = login()
if cook is not None:
Urge(cook, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
import random
import traceback
import logging
import log_settings
import json
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
from collections import Counter
auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
auto_reply_url = "http://earth.iyanzhi.com/api/v1/reply/create"
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
my_sender = 'lixiaofang@igengmei.com'
my_pass = 'tg5AVKBB8jLQGBET'
my_user6 = "lixiaofang@igengmei.com"
# auto_click_url = "http://earth.igengmei.env/api/v1/like"
# auto_reply_url = "http://earth.igengmei.env/api/v1/reply/create"
# auto_follow_url = "http://earth.igengmei.env/api/v1/follow"
# auto_urge_url = "http://earth.igengmei.env/api/v1/user/urge"
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.mysql',
# 'NAME': 'alpha',
# 'USER': 'work',
# 'PASSWORD': 'Gengmei123',
# 'HOST': 'rm-2zeaut61u9sm21m0b.mysql.rds.aliyuncs.com',
# 'PORT': '3306',
# 'OPTIONS': {
# "init_command": "SET foreign_key_checks = 0;",
# "charset": "utf8mb4",
# },
# }
# }
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'alpha',
'USER': 'work',
'PASSWORD': 'oars152!traipseize738',
'HOST': '172.17.40.136',
'PORT': '3306',
'OPTIONS': {
"init_command": "SET foreign_key_checks = 0;",
"charset": "utf8mb4",
}
}
}
host = DATABASES['default']['HOST']
user = DATABASES['default']['USER']
port = DATABASES['default']['PORT']
db = DATABASES['default']['NAME']
passwd = DATABASES['default']['PASSWORD']
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/data/log/cybertron/app/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def login():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id):
try:
post_dict = {
'type': 0,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
get_error(response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def reply(cookies_get, id, content):
try:
post_dict = {
'topic_id': id,
'content': content
}
response = requests.post(url=auto_reply_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
get_error(response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(minutest, minutest2):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=minutest)
yes_time2 = now - datetime.timedelta(minutes=minutest2)
return yes_time, yes_time2
except:
return None
def time_now(minutest):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(hours=minutest)
return yes_time,now
except:
return None
def time_convs(numtime, numtime2):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
yes_time_str = yes_time_str + ' 23:59:59.000000'
yes_time2 = now - datetime.timedelta(days=numtime2)
yes_time_str2 = yes_time2.strftime('%Y-%m-%d')
yes_time_str2 = yes_time_str2 + ' 00:00:00.000000'
return yes_time_str, yes_time_str2
except:
return None
def get_comment():
try:
data = open("/srv/apps/cybertron/guanshui", "r")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
return comment
except:
return None
def get_comments():
try:
data = open("/srv/apps/cybertron/guanshui", "r")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num1 = random.randint(0, 200)
num2 = random.randint(200, 400)
num3 = random.randint(400, len(list_guanshui))
comment1 = list_guanshui[num1 - 1]
comment2 = list_guanshui[num2 - 1]
comment3 = list_guanshui[num3 - 1]
comment_list = [comment1, comment2, comment3]
return comment_list
except:
return None
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
get_error(response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def Urge(cookies_get, id):
try:
post_dict = {
'id': id
}
response = requests.post(url=auto_urge_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
get_error(response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def get_offline_comment():
try:
data = open("/srv/apps/cybertron/comment.txt", "r")
list_guanshui = []
for i in data:
list_guanshui.append(i)
num1 = random.randint(0, 200)
num2 = random.randint(200, 300)
num3 = random.randint(300, 400)
num4 = random.randint(400, len(list_guanshui))
comment1 = list_guanshui[num1 - 1]
comment2 = list_guanshui[num2 - 1]
comment3 = list_guanshui[num3 - 1]
comment4 = list_guanshui[num4 - 1]
comment_list = [comment1, comment2, comment3, comment4]
return comment_list
except:
return None
# def logins():
# try:
# user_id = get_majia()
#
# cookies = get_cookies(user_id)
#
# if cookies is not None:
# return {'sessionid': cookies}
#
# except:
#
# logging.error("catch exception,logins:%s" % traceback.format_exc())
#
# return None
def get_user_id():
user_data = open("/data/log/cybertron/app/user_id.txt", "r")
user_list = []
for i in user_data.readlines():
user_list.append(int(i.strip()))
return user_list
def send_email(stat_data):
ret = True
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=1)
yes_time_str = yes_time.strftime('%Y%m%d')
try:
msg = MIMEText(stat_data, 'plain', 'utf-8')
msg['From'] = formataddr(["李小芳", my_sender])
msg["To"] = formataddr(["李小芳", my_user6])
msg['Subject'] = str(datetime.date.today()) + "like的自动点赞出问题了"
server = smtplib.SMTP_SSL("smtp.exmail.qq.com", 465)
server.login(my_sender, my_pass)
server.sendmail(my_sender, [my_user6], msg.as_string())
server.quit()
return ret
except Exception:
ret = False
logging.error("catch exception,main:%s" % traceback.format_exc())
def get_error(line):
try:
if len(line) > 1:
data_dict = json.loads(line)
if data_dict["error"] != 0:
stat_data = str(line)
ret = send_email(stat_data)
if ret:
logging.info('like query统计邮件发送成功')
else:
logging.info('like query统计邮件发送失败')
else:
pass
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......@@ -6,146 +6,32 @@ import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_convs, follow, click
from auto_request import host, user, db, passwd
auto_follow_url = "http://earth.iyanzhi.com/api/v1/follow"
auto_click_url = "http://earth.iyanzhi.com/api/v1/like"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = []
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1, len(list))
user_id = list[maj - 1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id = get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def click(cookies_get, id):
try:
post_dict = {
'type': 0,
'id': id
}
response = requests.post(url=auto_click_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def follow(cookies_get, id):
try:
post_dict = {
'type': 1,
'id': id
}
response = requests.post(url=auto_follow_url,
cookies=cookies_get,
data=post_dict)
print(response.text, 'url')
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
def get_star_user_id(numtime1, numtime2):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_star_user_id(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
cursor.execute(
"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()
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_topic_id(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
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 user_id,id FROM topic WHERE is_online=1 and content_level in (4,5) and create_time > '%s' and create_time < '%s' " % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
user_id_list = list(data)
logging.info("Database version : %s " % user_id_list)
topic_id_list = []
if user_id_list:
for i in user_id_list:
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 None
......@@ -158,41 +44,47 @@ if __name__ == "__main__":
for i in time_list:
numtime = time_conv(i)
numtime1, numtime2 = time_convs(i + 1, i - 1)
user_id = get_star_topic_id(numtime)
user_topic_id = get_star_user_id(numtime1, numtime2)
urge_num = random.randint(0, 1)
try:
for i in range(urge_num):
for j in user_id:
for j in user_topic_id and user_topic_id:
id = int(j[0])
id = int(j[1])
urge_num = random.randint(0, 1)
for i in range(urge_num):
time.sleep(random.randint(1, 10))
time.sleep(random.randint(10, 20))
cookies = logins()
cookies = login()
if cookies is not None:
click(cookies, id)
time.sleep(300)
if cookies is not None:
click(cookies, id)
except:
pass
urge_num = random.randint(1, 2)
user_id = get_star_user_id(numtime1)
for i in range(urge_num):
try:
user_id = get_star_user_id(numtime)
for j in user_id and user_id:
for j in user_id:
id = int(j[0])
id = int(j[0])
for i in range(1):
time.sleep(random.randint(1, 10))
time.sleep(random.randint(10, 20))
cookies = logins()
cookies = login()
if cookies is not None:
follow(cookies, id)
if cookies is not None:
follow(cookies, id)
except:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -3,113 +3,33 @@ import time
import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
from auto_request import login, time_convs, Urge
from auto_request import host, user, db, passwd
def get_majia():
def get_star_useid(numtime1, numtime2):
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list))
user_id=list[maj-1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id=get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def Urge(cookies_get, id):
try:
post_dict = {
'id': id
}
response = requests.post(url=auto_urge_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_star_useid(numtime):
try:
db = pymysql.connect(host="172.17.40.144", user='work',
passwd='oars152!traipseize738',
db="alpha", port=3306)
cursor = db.cursor()
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"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)
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and content_level in (4,5) and create_time > '%s' and create_time < '%s'" % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
db.close()
return user_id
topic_id_list = []
for i in user_id and user_id:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0 ")
data = cursor.fetchall()
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())
......@@ -119,27 +39,14 @@ def get_star_useid(numtime):
if __name__ == "__main__":
try:
time_list = [1,2,3,4,5,6,7]
for i in time_list:
numtime = time_conv(i)
user_id = get_star_useid(numtime)
for j in user_id:
id = int(j[0])
for i in range(1):
time.sleep(random.randint(10, 50))
cookies = logins()
if cookies is not None:
Urge(cookies, id)
numtime1, numtime2 = time_convs(8, 0)
user_id = get_star_useid(numtime1, numtime2)
for j in user_id and user_id:
id = int(j[0])
for i in range(1):
cookies = login()
if cookies is not None:
Urge(cookies, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
import pymysql
import random
import pandas as pd
import traceback
from log_settings import *
import logging
auto_urge_url = "http://earth.iyanzhi.com/api/v1/user/urge"
def get_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
maj = random.randint(1,len(list))
user_id=list[maj-1]
return user_id
except:
logging.error("catch exception,get_majia:%s" % traceback.format_exc())
return None
def get_cookies(user_id):
try:
with open("/srv/apps/cybertron/user_session.txt", 'r') as f:
try:
data = f.readlines()
except:
data = None
list = []
for i in data:
list.append(i.strip('\n').split(","))
for i in list:
if user_id == i[0]:
return (i[1])
except:
return None
def logins():
try:
user_id=get_majia()
cookies = get_cookies(user_id)
if cookies is not None:
return {'sessionid': cookies}
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
return None
def Urge(cookies_get, id):
try:
post_dict = {
'id': id
}
response = requests.post(url=auto_urge_url,
cookies=cookies_get,
data=post_dict)
logging.info("response.text:%s" % response.text)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
def time_conv(numtime):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(days=numtime)
yes_time_str = yes_time.strftime('%Y-%m-%d')
return yes_time_str
except:
return None
def get_data(numtime):
try:
db = pymysql.connect(host="172.17.40.144", 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%%%%' and user_id in (select user_id from user_extra where is_shadow = 0)" % 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
if __name__ == "__main__":
try:
time_list = [1,2,3,4,5,6,7]
for i in time_list:
numtime = time_conv(i)
user_id = get_data(numtime)
urge_num = random.randint(0, 2)
for i in range(urge_num):
for j in user_id:
id = int(j[0])
time.sleep(random.randint(3, 10))
cookies=logins()
if cookies is not None:
Urge(cookies, id)
time.sleep(300)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_convs, Urge
from auto_request import host, port, passwd, user, db
import threading
def get_data(numtime1, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time > '%s' and create_time < '%s'" % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
topic_id_list = []
for i in user_id and user_id:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0 ")
data = cursor.fetchall()
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 None
if __name__ == "__main__":
try:
time_list = [1, 2, 3, 4, 5, 6, 7]
numtime1, numtime2 = time_convs(8, 0)
logging.info("get numtime1:%s" % numtime1)
logging.info("get numtime2:%s" % numtime2)
user_id = get_data(numtime1, numtime2)
urge_num = random.randint(0, 1)
if urge_num == 1:
for j in user_id and user_id:
id = int(j[0])
# time.sleep(random.randint(10, 50))
cookies = login()
if cookies is not None:
Urge(cookies, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_convs, Urge
from auto_request import host, port, passwd, user, db
import threading
def get_data(numtime1, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time > '%s' and create_time < '%s'" % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
topic_id_list = []
for i in user_id and user_id:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0 ")
data = cursor.fetchall()
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 None
if __name__ == "__main__":
try:
time_list = [1, 2, 3, 4, 5, 6, 7]
numtime1, numtime2 = time_convs(8, 0)
logging.info("get numtime1:%s" % numtime1)
logging.info("get numtime2:%s" % numtime2)
user_id = get_data(numtime1, numtime2)
for j in user_id and user_id:
urge_num = random.randint(0, 1)
if urge_num == 1:
id = int(j[0])
# time.sleep(random.randint(10, 50))
cookies = login()
if cookies is not None:
Urge(cookies, id)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
import requests
import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
from auto_request import login, time_convs, Urge
from auto_request import host, port, passwd, user, db
import threading
def get_data(numtime1, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and create_time > '%s' and create_time < '%s'" % (
numtime1, numtime2))
data = cursor.fetchall()
user_id = list(data)
topic_id_list = []
for i in user_id and user_id:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0 ")
data = cursor.fetchall()
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 None
if __name__ == "__main__":
try:
time_list = [1, 2, 3, 4, 5, 6, 7]
for i in time_list:
numtime1, numtime2 = time_convs(i + 1, i - 1)
logging.info("get numtime1:%s" % numtime1)
user_id = get_data(numtime1, numtime2)
urge_num = random.randint(0, 1)
if urge_num == 1:
for i in range(urge_num):
try:
for j in user_id and user_id:
id = int(j[0])
# time.sleep(random.randint(10, 50))
cookies = login()
if cookies is not None:
Urge(cookies, id)
except:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
This diff is collapsed.
import requests
import time
import datetime
import pymysql
import random
import traceback
from log_settings import *
import logging
import threading
from auto_request import login, time_convs, Urge
from auto_request import host, user, db, passwd
def get_data(numtime):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"select distinct(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))
data = cursor.fetchall()
user_id = list(data)
topic_id_list = []
for i in user_id and user_id:
cursor.execute(
"select user_id from user_extra where user_id =" + str(i[0]) + " and is_shadow =0 ")
data = cursor.fetchall()
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 None
if __name__ == "__main__":
try:
numtime1, numtime2 = time_convs(3, 2)
user_id = get_data(numtime1)
for i in user_id and user_id:
urge_num = random.randint(0, 1)
if urge_num == 1:
cook = login()
if cook is not None:
Urge(cook, i)
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -48,7 +48,7 @@ def get_cook():
dicts = get_cook()
with open("user_session.txt", 'w') as f:
with open("/data/log/cybertron/app/user_session.txt", 'w') as f:
for key, value in dicts.items():
f.write(key)
f.write(",")
......
This diff is collapsed.
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