search.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. """
  2. 搜索API
  3. """
  4. from flask import Blueprint
  5. from flask import request
  6. import api
  7. from facebook import FackBookBrowser
  8. search_opt = Blueprint('search', __name__)
  9. @search_opt.route('/user', methods=["POST"])
  10. def search_user():
  11. """
  12. 搜索抖音用户信息
  13. :return:
  14. """
  15. request_body = request.json
  16. user_url = request_body.get('url')
  17. api.assert_not_none(user_url, '用户链接不能为空')
  18. browser = FackBookBrowser(api.get_idle_account())
  19. result = browser.search_user(user_url)
  20. return api.success(result)
  21. @search_opt.route('/batch-users', methods=["POST"])
  22. def batch_users():
  23. """
  24. 批量搜索抖音用户信息
  25. :return:
  26. """
  27. request_body = request.json
  28. user_urls = request_body.get('urls')
  29. api.assert_not_none(user_urls, '用户链接不能为空')
  30. browser = FackBookBrowser(api.get_idle_account())
  31. result = browser.batch_users(user_urls)
  32. return api.success(result)
  33. @search_opt.route('/post', methods=["POST"])
  34. def search_post():
  35. """
  36. 搜索博文
  37. :return:
  38. """
  39. request_body = request.json
  40. post_url = request_body.get('url')
  41. api.assert_not_none(post_url, '博文链接不能为空')
  42. browser = FackBookBrowser(api.get_idle_account())
  43. result = browser.invoke(browser.search_post, url=post_url)
  44. return api.success(result)
  45. @search_opt.route('/batch-notes', methods=["POST"])
  46. def batch_notes():
  47. """
  48. 根据关键字搜索抖音笔记、视频
  49. :return:
  50. """
  51. request_body = request.json
  52. note_urls = request_body.get('urls')
  53. api.assert_not_none(note_urls, '作品链接不能为空')
  54. browser = FackBookBrowser(api.get_idle_account())
  55. result = browser.batch_notes(note_urls)
  56. return api.success(result)