""" 搜索API """ from flask import Blueprint from flask import request import api from instagram import InstagramBrowser search_opt = Blueprint('search', __name__) @search_opt.route('/user', methods=["POST"]) def search_user(): """ 搜索抖音用户信息 :return: """ request_body = request.json user_url = request_body.get('url') api.assert_not_none(user_url, '用户链接不能为空') browser = InstagramBrowser(api.get_idle_account()) result = browser.search_user(user_url) return api.success(result) @search_opt.route('/batch-users', methods=["POST"]) def batch_users(): """ 批量搜索用户信息 :return: """ request_body = request.json user_urls = request_body.get('urls') api.assert_not_none(user_urls, '用户链接不能为空') browser = InstagramBrowser(api.get_idle_account()) result = browser.batch_users(user_urls) return api.success(result) @search_opt.route('/blog', methods=["POST"]) def search_blog(): """ 搜索博文 :return: """ request_body = request.json blog_url = request_body.get('url') api.assert_not_none(blog_url, '博文链接不能为空') browser = InstagramBrowser(api.get_idle_account()) result = browser.__invoke__(browser.search_blog, url=blog_url) return api.success(result) @search_opt.route('/batch-notes', methods=["POST"]) def batch_notes(): """ 根据关键字搜索抖音笔记、视频 :return: """ request_body = request.json note_urls = request_body.get('urls') api.assert_not_none(note_urls, '作品链接不能为空') browser = InstagramBrowser(api.get_idle_account()) result = browser.batch_notes(note_urls) return api.success(result)