123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- """
- 搜索API
- """
- from flask import Blueprint
- from flask import request
- import api
- from tiktok import TikTokBrowser
- search_opt = Blueprint('search', __name__)
- @search_opt.route('/image-text-by-keyword', methods=["POST"])
- def search_keyword():
- """
- 根据关键字搜索抖音图文
- :return:
- """
- request_body = request.json
- keyword = request_body.get('keyword')
- api.assert_not_none(keyword, '关键字不能为空')
- phone = api.get_idle_account()
- browser = TikTokBrowser(phone)
- result = browser.search_image_text(keyword)
- return api.success(result)
- @search_opt.route('/image-text-by-author', methods=["POST"])
- def image_text_by_author():
- """
- 根据作者链接搜索抖音图文
- :return:
- """
- request_body = request.json
- author_url = request_body.get('authorUrl')
- size = request_body.get('size')
- api.assert_not_none(author_url, '作者链接不能为空')
- phone = api.get_idle_account()
- browser = TikTokBrowser(phone)
- result = browser.search_image_text_by_author(author_url, size)
- return api.success(result)
- @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 = TikTokBrowser(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 = TikTokBrowser(api.get_idle_phone())
- result = browser.batch_users(user_urls)
- return api.success(result)
- @search_opt.route('/batch-user-polish', methods=["POST"])
- def batch_user_unique_id():
- """
- 批量搜索抖音用户抖音号
- :return:
- """
- request_body = request.json
- sec_uids = request_body.get('secUids')
- api.assert_not_none(sec_uids, '用户id不能为空')
- browser = TikTokBrowser(api.get_idle_account())
- result = browser.batch_user_polish(sec_uids)
- return api.success(result)
- @search_opt.route('/item', methods=["POST"])
- def search_item():
- """
- 根据关键字搜索抖音笔记、视频
- :return:
- """
- request_body = request.json
- note_url = request_body.get('url')
- api.assert_not_none(note_url, '作品链接不能为空')
- browser = TikTokBrowser(api.get_idle_account())
- result = browser.invoke(func=browser.search_item, url=note_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 = TikTokBrowser(api.get_idle_account())
- result = browser.batch_notes(note_urls)
- return api.success(result)
|