Commit dae37642 authored by lixiaofang's avatar lixiaofang

majia new

parent 82a54b5e
This diff is collapsed.
......@@ -126,6 +126,7 @@ def time_conv():
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(minutes=15)
print(yes_time)
return yes_time
def get_topic_id(numtime):
......@@ -134,7 +135,7 @@ def get_topic_id(numtime):
db="alpha", port=3306)
cursor = db.cursor()
print("---------")
cursor.execute("SELECT id FROM topic WHERE create_time <= %s" ,(numtime))
cursor.execute("SELECT id FROM topic WHERE create_time >= %s" ,(numtime))
data = cursor.fetchall()
user_id = list(data)
......
......@@ -133,8 +133,6 @@ if __name__ == "__main__":
for i in range(urge_num):
cookies = index_first()
cook=login()
click(cook, rand_id)
......
......@@ -127,8 +127,6 @@ if __name__ == "__main__":
for i in range(urge_num):
cookies = index_first()
cook=logins()
click(cook, rand_id)
......
......@@ -4,7 +4,9 @@ import datetime
import pymysql
import random
import pandas as pd
import traceback
from .log_settings import *
import logging
auto_reply_url = "http://earth.igengmei.com/api/v1/reply/create"
......@@ -12,92 +14,115 @@ login_url = "http://earth.igengmei.com/api/account/login_pwd"
def index_first():
r1=requests.get(login_url)
return r1.cookies.get_dict()
try:
r1 = requests.get(login_url)
return r1.cookies.get_dict()
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return None
def get_majia():
data = open("batch user gen")
try:
data = open("batch user gen")
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
list=[]
for i in data:
list.append(i.strip('\n').strip(','))
# time.sleep(random.randint(0, 500))
# time.sleep(random.randint(0, 500))
maj = random.randint(1,len(list))
maj = random.randint(1,len(list))
user_id=list[maj-1]
user_id=list[maj-1]
print(user_id)
print(user_id)
return user_id
return user_id
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return None
def logins():
try:
# time.sleep(random.randint(300, 500))
# time.sleep(random.randint(300, 500))
user_id=get_majia()
user_id = get_majia()
cookies = index_first()
cookies = index_first()
if cookies is None:
logging.error("cookies is None!")
return None
post_dict={
'account_type':2,
'pwd':'123456',
'email':user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
post_dict = {
'account_type': 2,
'pwd': '123456',
'email': user_id
}
response = requests.post(
url=login_url,
data=post_dict,
cookies=cookies
)
headers=response.headers
headers = response.headers
cook = headers['Set-Cookie'].split(";")
cook = headers['Set-Cookie'].split(";")
cook = cook[0].split('=')[1]
cook = cook[0].split('=')[1]
print(response.text, 'url')
print(response.text, 'url')
print(cook)
print(cook)
return {'sessionid': cook}
return {'sessionid': cook}
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return None
def reply(cookies_get,id,content):
post_dict={
'topic_id':id,
'content':content
}
response=requests.post(url=auto_reply_url,
cookies=cookies_get,
data=post_dict)
try :
post_dict={
'topic_id':id,
'content':content
}
response=requests.post(url=auto_reply_url,
cookies=cookies_get,
data=post_dict)
print(response.text,'url')
logging.info("response.text :%s"%(response.text))
print(response.text,'url')
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
def time_conv(numtime):
now = datetime.datetime.now()
yes_time = now -datetime.timedelta(days=numtime)
yes_time_str=yes_time.strftime('%Y-%m-%d')
return yes_time_str
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):
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db="alpha", port=3306)
cursor = db.cursor()
# print("---------")
cursor.execute("SELECT id FROM topic WHERE create_time LIKE '%%%%%s%%%%' " %numtime)
data = cursor.fetchall()
topic_id = list(data)
print("Database version : %s " % topic_id)
db.close()
return topic_id
try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db="alpha", port=3306)
cursor = db.cursor()
# print("---------")
cursor.execute("SELECT id FROM topic WHERE create_time LIKE '%%%%%s%%%%' " %numtime)
data = cursor.fetchall()
topic_id = list(data)
print("Database version : %s " % topic_id)
db.close()
return topic_id
except:
return None
def get_comment():
......@@ -116,20 +141,26 @@ def get_comment():
if __name__ == "__main__":
time_list = [1,2,3,4,5,6,7]
try:
time_list = [1,2,3,4,5,6,7]
for i in time_list:
#time.sleep(random.randint(500,1500))
for i in time_list:
numtime = time_conv(i)
#time.sleep(random.randint(500,1500))
topic_id = get_topic_id(numtime)
numtime = time_conv(i)
for i in topic_id:
topic_id = get_topic_id(numtime)
cook = logins()
for i in topic_id:
comment = get_comment()
cook = logins()
reply(cook, i, comment)
comment = get_comment()
except:
reply(cook, i, comment)
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......@@ -17,16 +17,6 @@ def index_first():
return r1.cookies.get_dict()
# def get_majia():
#
# data = open("batch user gen")
#
# list=[]
# for i in data:
# list.append(i.strip('\n').strip(','))
#
# return list
def logins(id):
cookies = index_first()
......@@ -78,7 +68,7 @@ def get_follw_majia(numtime,id):
cursor.execute("select temp1.user_id,temp1.email,temp2.follow_id from account_user_auth temp1 left join "
"(select user_id,follow_id from user_follow) "
" temp2 on temp1.user_id=temp2.user_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_1dbAoA@shadow.com','s_1dholX@shadow.com','s_1EpLlt@shadow.com','s_1iyrBU@shadow.com')")
" temp2 on temp1.user_id=temp2.user_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','s_1iyrBU@shadow.com')")
data = cursor.fetchall()
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import logging
LOG_DIR = '/data/log/cybertron/app/'
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s %(levelname)s %(module)s.%(funcName)s Line:%(lineno)d %(message)s',
filename=os.path.join(LOG_DIR, 'filelog.log'),
)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
},
},
'formatters': {
'verbose': {
'format': '%(asctime)s %(levelname)s %(module)s.%(funcName)s Line:%(lineno)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
'profile': {
'format': '%(asctime)s %(message)s'
},
'raw': {
'format': '%(message)s'
}
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
# 默认的服务器Log(保存到log/filelog.log中, 通过linux的logrotate来处理日志的分割
'default': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(LOG_DIR, 'filelog.log'),
'formatter': 'verbose',
},
# 默认的服务器ERROR log
'default_err': {
'level': 'ERROR',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(LOG_DIR, 'error_logger.log'),
'formatter': 'verbose',
},
'exception_logger': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(LOG_DIR, 'exception_logger.log'),
'formatter': 'verbose',
},
'tracer_handler': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(LOG_DIR, 'tracer.log'),
'formatter': 'raw'
},
},
'loggers': {
'django': {
'handlers': ['default'],
'propagate': True,
'level': 'INFO',
},
'django.request': {
'handlers': ['default_err'],
'level': 'ERROR',
'propagate': False,
},
'exception_logger': {
'handlers': ['exception_logger'],
'level': 'INFO',
'propagate': False,
},
'gm_tracer.subscribe': {
'handlers': ['tracer_handler'],
'propagate': False,
'level': 'INFO'
},
},
}
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