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

fix auto_follow_per_5m_by_followed

parent 8e17c112
This diff is collapsed.
...@@ -3,7 +3,7 @@ import traceback ...@@ -3,7 +3,7 @@ import traceback
import logging import logging
from vest.request.auto_request import login, follow, time_conv from vest.request.auto_request import login, follow, time_conv
from vest.request.auto_request import host, user, db, passwd from vest.request.auto_request import host, user, db, passwd
from vest.data.majia_user_ids import majia_user_ids_list from vest.data.majia_user_ids import majia_user_ids_list, majia_user_ids_dict
from libs.error import logging_exception from libs.error import logging_exception
...@@ -12,7 +12,7 @@ def get_user_id(numtime): ...@@ -12,7 +12,7 @@ def get_user_id(numtime):
cursor = pc.cursor() cursor = pc.cursor()
majia_user_ids_tuple = tuple(majia_user_ids_list) majia_user_ids_tuple = tuple(majia_user_ids_list)
cursor.execute( cursor.execute(
"SELECT user_id FROM user_follow WHERE create_time > '%s' and follow_id in %s " % (numtime, str(majia_user_ids_tuple)) "SELECT user_id, follow_id FROM user_follow WHERE create_time > '%s' and follow_id in %s " % (numtime, str(majia_user_ids_tuple))
) )
data_comment = cursor.fetchall() data_comment = cursor.fetchall()
return data_comment and [i for i in data_comment] or [] return data_comment and [i for i in data_comment] or []
...@@ -22,10 +22,11 @@ def auto_follow_per_5m_by_followed(): ...@@ -22,10 +22,11 @@ def auto_follow_per_5m_by_followed():
# 如果马甲被用户关注,马甲即反向关注用户, 被关注5分钟后 # 如果马甲被用户关注,马甲即反向关注用户, 被关注5分钟后
try: try:
numtime1, numtime2 = time_conv(1, 5) numtime1, numtime2 = time_conv(1, 5)
user_ids = get_user_id(numtime2) users = get_user_id(numtime2)
try: try:
for user_id in user_ids and user_ids: for user in users and users:
cookies = login() user_id = user[0]
cookies = login(majia_user_ids_dict.get(user[1]))
if cookies is not None: if cookies is not None:
follow(cookies, user_id) follow(cookies, user_id)
except: except:
......
...@@ -82,9 +82,10 @@ def get_cookies(user_id): ...@@ -82,9 +82,10 @@ def get_cookies(user_id):
return None return None
def login(): def login(user_id=None):
try: try:
user_id = get_majia() if not user_id:
user_id = get_majia()
logging.info("get user_id:%s" % user_id) logging.info("get user_id:%s" % user_id)
cookies = get_cookies(user_id) cookies = get_cookies(user_id)
......
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