Commit 5686973a authored by lixiaofang's avatar lixiaofang

S

parents b9e8c2b3 44b068ac
This diff is collapsed.
......@@ -4,7 +4,7 @@ import random
import traceback
from log_settings import *
import logging
from auto_request import login, click, time_conv
from auto_request import login, click, time_convs
from auto_request import host, user, db, passwd
......@@ -13,24 +13,37 @@ def get_data(numtime, numtime2):
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 )")
"SELECT distinct(user_id) FROM topic WHERE is_online=1 and content_level in (4,5,6) and (create_time >= '%s' and create_time <= '%s')" % (
numtime, numtime2))
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
for i in topic_id and topic_id:
cursor.execute(
"select user_id,is_shadow from user_extra where user_id =" + str(
i[0]) + " and is_online =1 and is_deleted =0")
data = cursor.fetchall()
user_id = list(data)
if (user_id and user_id[0][1] == 0) or len(user_id) == 0:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
return topic_id
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
if __name__ == "__main__":
try:
numtime, numtime2 = time_conv(15, 5)
numtime, numtime2 = time_convs(1, 7)
user_id = get_data(numtime, numtime2)
dicts = {}
logging.info("get user_id:%s" % user_id)
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)
click(cook, i[1])
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -10,28 +10,29 @@ import redis
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
from collections import Counter
my_sender = 'lixiaofang@igengmei.com'
my_pass = 'tg5AVKBB8jLQGBET'
my_user6 = "lixiaofang@igengmei.com"
auto_click_url = "http://earth.gmapp.env/api/v1/like"
auto_reply_url = "http://earth.gmapp.env/api/v1/reply/create"
auto_follow_url = "http://earth.gmapp.env/api/v1/follow"
auto_urge_url = "http://earth.gmapp.env/api/v1/user/urge"
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"
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'alpha',
'USER': 'work',
'PASSWORD': 'Gengmei123!',
'HOST': '172.21.36.16',
'PASSWORD': 'oars152!traipseize738',
'HOST': '172.17.40.136',
'PORT': '3306',
'OPTIONS': {
"init_command": "SET foreign_key_checks = 0;",
"charset": "utf8mb4",
},
}
}
}
......@@ -136,7 +137,8 @@ def click(cookies_get, id):
data=post_dict)
logging.info("response.text:%s" % response.text)
get_error(response.text)
get_error(response.text, "click", id)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
......@@ -154,7 +156,7 @@ def reply(cookies_get, id, content):
data=post_dict)
logging.info("response.text:%s" % response.text)
get_error(response.text)
get_error(response.text, "reply", id)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
......@@ -219,6 +221,9 @@ def time_convs(numtime, numtime2):
yes_time_str2 = yes_time2.strftime('%Y-%m-%d')
yes_time_str2 = yes_time_str2 + ' 00:00:00.000000'
logging.info("get yes_time_str:%s"%yes_time_str)
logging.info("get yes_time_str2:%s"%yes_time_str2)
return yes_time_str, yes_time_str2
except:
return None
......@@ -232,9 +237,7 @@ def get_comment():
list_guanshui.append(i)
num = random.randint(0, len(list_guanshui))
comment = list_guanshui[num - 1]
return comment
except:
......@@ -295,7 +298,7 @@ def follow(cookies_get, id):
data=post_dict)
logging.info("response.text:%s" % response.text)
get_error(response.text)
get_error(response.text, "follow", id)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
......@@ -311,7 +314,7 @@ def Urge(cookies_get, id):
data=post_dict)
logging.info("response.text:%s" % response.text)
get_error(response.text)
get_error(response.text, "Urge", id)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
......@@ -387,12 +390,12 @@ def send_email(stat_data):
logging.error("catch exception,main:%s" % traceback.format_exc())
def get_error(line):
def get_error(line, type, id):
try:
if len(line) > 1:
data_dict = json.loads(line)
if data_dict["error"] != 0:
stat_data = str(line)
stat_data = str(line) + str(type) + str(id)
ret = send_email(stat_data)
if ret:
logging.info('like query统计邮件发送成功')
......@@ -449,7 +452,7 @@ def reply_answer(cookies_get, id, content):
data=post_dict)
logging.info("response.text:%s" % response.text)
get_error(response.text)
get_error(response.text, "reply", id)
return response.text
except:
......@@ -459,7 +462,7 @@ def reply_answer(cookies_get, id, content):
def set_reply_to_redis():
try:
redis_url = "redis://:Gengmei123@172.21.52.16:6379/15"
redis_url = "redis://:gHtmeIqBhVHtH8MG@172.17.40.140:6379/1"
redis_client = redis.StrictRedis.from_url(redis_url)
return redis_client
......@@ -480,7 +483,7 @@ def reply2(cookies_get, id, content, replied_id):
data=post_dict)
logging.info("response.text:%s" % response.text)
get_error(response.text)
get_error(response.text, "reply2", id)
except:
logging.error("catch exception,logins:%s" % traceback.format_exc())
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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