Commit dd262629 authored by zhongshangwu's avatar zhongshangwu

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

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