def get_profile(user_id): # 判断数据库是否存在该用户信息 user = get_user_by_uid(user_id) if user: storage.info('ID为{id}的用户信息已经存在于数据库中'.format(id=user_id)) else: user = get_url_from_web(user_id) return user
def get_profile(user_id): user = get_user_by_uid(user_id) if user: storage.info('user {id} has already crawled'.format(id=user_id)) set_seed_crawled(user_id, 1) else: user = get_url_from_web(user_id) if user is not None: set_seed_crawled(user_id, 1) else: set_seed_crawled(user_id, 1) return user
def get_profile(user_id): # 判断数据库是否存在该用户信息 user = get_user_by_uid(user_id) if user: storage.info('ID为{id}的用户信息已经存在于数据库中'.format(id=user_id)) set_seed_crawled(user_id, 1) else: user = get_url_from_web(user_id) if user is not None: set_seed_crawled(user_id, 1) else: set_seed_crawled(user_id, 1) return user
def get_profile(user_id): # 判断数据库是否存在该用户信息 user = get_user_by_uid(user_id) if user: # 防止在插入数据库的时候encode()出问题 for key in user.__dict__: if user.__dict__[key] is None: setattr(user, key, '') storage.info('ID为{id}的用户信息已经存在于数据库中'.format(id=user_id)) else: user = get_url_from_web(user_id) return user
def get_profile(user_id): """ :param user_id: uid :return: user info and is crawled or not """ user = get_user_by_uid(user_id) if user: storage.info('user {id} has already crawled'.format(id=user_id)) set_seed_crawled(user_id, 1) is_crawled = 1 else: user = get_url_from_web(user_id) if user is not None: set_seed_crawled(user_id, 1) else: set_seed_crawled(user_id, 2) is_crawled = 0 return user, is_crawled
def get_profile(user_id, domain): """ :param user_id: uid :return: user info and is crawled or not """ user = get_user_by_uid(user_id) if user: storage.info('user {id} has already crawled'.format(id=user_id)) set_seed_crawled(user_id, 1) is_crawled = 1 else: user = get_url_from_web(user_id, domain) if user is not None: set_seed_crawled(user_id, 1) else: set_seed_crawled(user_id, 2) is_crawled = 0 return user, is_crawled