search.py 822 B

12345678910111213141516171819202122232425262728
  1. """
  2. 搜索API
  3. """
  4. from flask import Blueprint
  5. from flask import request
  6. import api
  7. from huitun import HuiTunBrowser
  8. from util import lock_util
  9. from xhs import XhsBrowser
  10. from playwright.sync_api import Playwright, sync_playwright
  11. search_opt = Blueprint('search', __name__)
  12. @search_opt.route('/note', methods=["POST"])
  13. def search_note():
  14. """
  15. 根据关键字搜索抖音笔记
  16. :return:
  17. """
  18. request_body = request.json
  19. playwright = sync_playwright().start()
  20. browser = HuiTunBrowser(lock_util.get_idle_phone('huitun'), playwright)
  21. result = browser.search_note(request_body.get('tagName'), request_body.get('searchLimit'))
  22. xhs_browser = XhsBrowser(lock_util.get_idle_phone('xhs'), playwright)
  23. xhs_browser.polish_huitun_note(result)
  24. playwright.stop()
  25. return api.success(result)