Commit d2a85655 authored by 吴升宇's avatar 吴升宇

fix auto reply majia user

parent 89a54334
crontab:
cp crontab.py /data/log/physical/app/crontab.py && python /data/log/physical/app/crontab.py && python /data/log/physical/app/crontabs.py
celery:
celery -A physcical worker -c 1 -Q vest -l debug
celery -A physical worker -c 1 -Q vest -l debug
......@@ -55,8 +55,3 @@ celery -A physical beat
### physical策略端脚本
在Alp-Test-Cos-test001服务器上,通过crontab -l查看
更新脚本
```bash
make crontab
```
\ No newline at end of file
......@@ -23,18 +23,13 @@ def eta_2_push_time(eta):
return push_time
def get_rand_time(hourlow=0, hourup=13, minutelow=0, miniteup=60):
def get_rand_time(hourlow=0, hourup=13, minutelow=0, minuteup=60):
hours = random.randint(hourlow, hourup)
minutes = random.randint(minutelow, miniteup)
now_time = NOW + timedelta(hours=hours, minutes=minutes)
minutes = random.randint(minutelow, minuteup)
# todo redis会自动给加8个小时,所以这边先写死减少8小时
now_time = NOW + timedelta(hours=hours, minutes=minutes) - timedelta(hours=8)
time = eta_2_push_time(now_time.strftime("%Y-%m-%d %H:%M:%S"))
print(datetime.fromtimestamp(time))
return datetime.fromtimestamp(time)
......@@ -42,7 +42,7 @@ def batch_handle(auto_click_list):
try:
cookies = login()
if cookies is not None:
click.async_apply(args=(cookies, topic_id), eta=get_rand_time())
click.apply_async(args=(cookies, topic_id), eta=get_rand_time())
# click(cookies, topic_id)
except:
pass
......
......@@ -44,7 +44,7 @@ def batch_handle(auto_click_list):
cookies = login()
if cookies is not None:
# click(cookies, topic_id)
click.async_apply(args=(cookies, topic_id), eta=get_rand_time(hourup=1))
click.apply_async(args=(cookies, topic_id), eta=get_rand_time(hourup=1))
except:
pass
......
......@@ -30,7 +30,7 @@ def batch_handle(auto_follow_list):
cookies = login()
if cookies is not None:
# follow(cookies, user_id)
follow.async_apply(args=(cookies, user_id), eta=get_rand_time())
follow.apply_async(args=(cookies, user_id), eta=get_rand_time())
except:
pass
......
......@@ -29,7 +29,7 @@ def batch_handle(auto_follow_list):
cookies = login()
if cookies is not None:
# follow(cookies, user_id)
follow.async_apply(args=(cookies, user_id), eta=get_rand_time())
follow.apply_async(args=(cookies, user_id), eta=get_rand_time())
except:
pass
......
......@@ -41,7 +41,7 @@ def batch_handle(auto_follow_list):
cookies = login()
if cookies is not None:
# follow(cookies, user_id)
follow.async_apply(args=(cookies, user_id), eta=get_rand_time(hourup=1))
follow.apply_async(args=(cookies, user_id), eta=get_rand_time(hourup=1))
except:
pass
......
......@@ -30,7 +30,7 @@ def auto_follow_per_5m_by_followed():
cookies = login(str(majia_user_ids_dict.get(str(user[1]))))
if cookies is not None:
# follow(cookies, user_id)
follow.async_apply(args=(cookies, user_id), eta=get_rand_time())
follow.apply_async(args=(cookies, user_id), eta=get_rand_time())
except:
pass
......
......@@ -57,7 +57,7 @@ def batch_handle(pictorial_id_list):
if cookies is not None:
comment = judge_pictorial_info_get_comment(pictorial_id)
# pictorial_reply(cookies, pictorial_id, comment)
pictorial_reply.async_apply(args=(cookies, pictorial_id, comment), eta=get_rand_time())
pictorial_reply.apply_async(args=(cookies, pictorial_id, comment), eta=get_rand_time())
except:
pass
......
import pymysql
import traceback
import logging
import json
import random
from threading import Thread
from vest.request.auto_request import login, time_convs, get_answer_data, reply_answer, get_majia, \
......@@ -34,13 +35,14 @@ def batch_handle(topic_id_list):
comment = judge_topic_info_get_comment(topic_id)
if comment:
# reply(cookies, topic_id, comment)
reply.async_apply(args=(cookies, topic_id, comment), eta=get_rand_time())
reply.apply_async(args=(cookies, topic_id, comment), eta=get_rand_time())
else:
comment1, comment2 = get_answer_data()
response = reply_answer(cookies, topic_id, comment1)
response = json.loads(response)
cookies = login()
reply_id = response["data"]["id"]
reply2.async_apply(args=(cookies, topic_id, comment2, reply_id), eta=get_rand_time())
reply2.apply_async(args=(cookies, topic_id, comment2, reply_id), eta=get_rand_time())
......
import pymysql
import traceback
import logging
import json
from threading import Thread
from vest.request.auto_request import login, time_conv_hour, get_answer_data, reply_answer, get_majia, \
set_reply_to_redis, judge_topic_info_get_comment, reply, reply2
......@@ -33,13 +34,14 @@ def batch_handle(topic_id_list):
comment = judge_topic_info_get_comment(topic_id)
if comment:
# reply(cookies, topic_id, comment)
reply.async_apply(args=(cookies, topic_id, comment), eta=get_rand_time(hourup=1))
reply.apply_async(args=(cookies, topic_id, comment), eta=get_rand_time(hourup=1))
else:
comment1, comment2 = get_answer_data()
response = reply_answer(cookies, topic_id, comment1)
response = json.loads(response)
cookies = login()
reply_id = response["data"]["id"]
reply2.async_apply(args=(cookies, topic_id, comment2, reply_id), eta=get_rand_time(hourup=1))
reply2.apply_async(args=(cookies, topic_id, comment2, reply_id), eta=get_rand_time(hourup=1))
except:
logging_exception()
......
......@@ -139,6 +139,7 @@ def click(cookies_get, id):
cookies=cookies_get,
data=post_dict)
print(response.text)
logging.info("response.text:%s" % response.text)
get_error(response.text, "click", id)
......@@ -159,6 +160,7 @@ def reply(cookies_get, id, content):
cookies=cookies_get,
data=post_dict)
print(response.text)
logging.info("response.text:%s" % response.text)
get_error(response.text, "reply", id)
except:
......@@ -281,6 +283,7 @@ def follow(cookies_get, id):
cookies=cookies_get,
data=post_dict)
print(response.text)
logging.info("response.text:%s" % response.text)
get_error(response.text, "follow", id)
except:
......@@ -448,6 +451,7 @@ def reply2(cookies_get, id, content, replied_id):
cookies=cookies_get,
data=post_dict)
print(response.text)
logging.info("response.text:%s" % response.text)
get_error(response.text, "reply2", id)
except:
......@@ -467,6 +471,7 @@ def pictorial_reply(cookies_get, id, content):
cookies=cookies_get,
data=post_dict)
print(response.text)
logging.info("response.text:%s" % response.text)
get_error(response.text, "pictorial_reply", id)
except:
......@@ -610,7 +615,9 @@ def judge_topic_info_get_comment(topic_id):
comment = get_face_comment()
# 原始评论
else:
comment = get_comment()
# 返回空就会去拿多级评论
if random.randint(0, 1):
comment = get_comment()
else:
# 判断有没有商品信息
......@@ -628,7 +635,9 @@ def judge_topic_info_get_comment(topic_id):
comment = get_face_comment()
# 原始评论
else:
comment = get_comment()
# 返回空就会去拿多级评论
if random.randint(0, 1):
comment = get_comment()
logging.info("get judge_topic_info_get_comment:%s" % comment)
return comment
......
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