Commit dd262629 authored by zhongshangwu's avatar zhongshangwu

修复小红书入库马甲用户逻辑

parent 3bffffdb
Pipeline #1978 passed with stage
...@@ -3,6 +3,7 @@ import os ...@@ -3,6 +3,7 @@ import os
from datetime import datetime from datetime import datetime
import json import json
import requests import requests
import random
from random import randint from random import randint
from django.core.management import BaseCommand from django.core.management import BaseCommand
from engine.rpc import rpc_invoker from engine.rpc import rpc_invoker
...@@ -16,7 +17,7 @@ from engine.logger import info_logger, error_logger, logging_exception ...@@ -16,7 +17,7 @@ from engine.logger import info_logger, error_logger, logging_exception
IMAGE_SUFFIX = '-w' IMAGE_SUFFIX = '-w'
FILE_PATH = '/Users/haowei/Desktop/xhs/' FILE_PATH = '/Users/zhongshangwu/workspace/gengmei/like/saturn/xiaohongshu/'
class Command(BaseCommand): class Command(BaseCommand):
...@@ -37,23 +38,32 @@ class Command(BaseCommand): ...@@ -37,23 +38,32 @@ class Command(BaseCommand):
second_pictorial_error_comments = [] second_pictorial_error_comments = []
second_reply_error_create = [] second_reply_error_create = []
shadow_user_ids = []
def del_cache(self): def del_cache(self):
for obj in self.del_cache_keys: for obj in self.del_cache_keys:
ins_cache.delete(obj) ins_cache.delete(obj)
def load_shadow_users(self):
data = rpc_invoker['venus/community/crawl/load_shawdow_user'](
start_user_id=self.user_id_start,
end_user_id=self.user_id_start + 5000
).unwrap()
print(data, ">>>>>")
self.shadow_user_ids = data
def get_random_user_id(self): def get_random_user_id(self):
# 随机获取用户ID # 随机获取用户ID
while True: return random.choice(self.shadow_user_ids)
index = randint(0, 5000) # while True:
user_id = self.user_id_start + index # index = randint(0, 5000)
data = rpc_invoker['venus/community/user/is_shadow'](user_id=user_id).unwrap() # user_id = self.user_id_start + index
if not data: # data = rpc_invoker['venus/community/user/is_shadow'](user_id=user_id).unwrap()
continue # if not data:
ret = data.get('user_id') # continue
if ret: # ret = data.get('user_id')
return user_id # if ret:
# return user_id
def get_user_id(self, id_, platform): def get_user_id(self, id_, platform):
# 获取用户ID 缓存记录保留用户关系 # 获取用户ID 缓存记录保留用户关系
...@@ -255,7 +265,7 @@ class Command(BaseCommand): ...@@ -255,7 +265,7 @@ class Command(BaseCommand):
return None, None return None, None
def handle(self, *args, **options): def handle(self, *args, **options):
self.load_shadow_users()
platform = 4 platform = 4
# 帖子 # 帖子
print('----- start deal topic at {} -----'.format(datetime.now().strftime('%Y-%m-%d %H:%M:%S %f'))) print('----- start deal topic at {} -----'.format(datetime.now().strftime('%Y-%m-%d %H:%M:%S %f')))
......
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