Commit 61f0ada2 authored by lixiaofang's avatar lixiaofang

add

parent d62d40fe
This diff is collapsed.
......@@ -4,7 +4,8 @@ import logging
import datetime
import json
from log_settings import *
from auto_request import login, time_conv_minute, get_answer_data, reply_answer, set_reply_to_redis, reply2
from auto_request import login, time_conv_minute, get_answer_data, reply_answer, set_reply_to_redis, reply2, logins, \
get_majia,get_majia_reply
from auto_request import host, user, db, passwd
......@@ -49,7 +50,8 @@ if __name__ == "__main__":
reply_data_comment = []
if user_id:
for i in user_id:
cook = login()
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
logging.info("get comment1:%s" % comment1)
logging.info("get comment2:%s" % comment2)
......@@ -61,7 +63,8 @@ if __name__ == "__main__":
reply_user_id = data_dict["data"]["user"]["id"]
topic_id = i[1]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": topic_id})
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": topic_id,
"majia_user_id": majia_user_id})
redis_client = set_reply_to_redis()
redis_client.hset(redis_key1, str(minute), json.dumps(reply_data_comment))
......@@ -73,7 +76,8 @@ if __name__ == "__main__":
redis_client.hdel(redis_key1, str(minute - 5))
if result:
for item in result:
cook = login()
majia_user_id = get_majia_reply(item["majia_user_id"])
cook = logins(majia_user_id)
reply2(cook, item["topic_id"], item["answer"], item["id"])
except:
......
......@@ -46,6 +46,22 @@ db = DATABASES['default']['NAME']
passwd = DATABASES['default']['PASSWORD']
def get_majia_reply(user_id):
try:
data = open("/srv/apps/cybertron/batch_user_gen")
list = []
for i in data :
if i != user_id:
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_majia():
try:
data = open("/srv/apps/cybertron/batch_user_gen")
......@@ -98,6 +114,22 @@ def login():
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 click(cookies_get, id):
try:
post_dict = {
......
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