PromoterInfoWebHook.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. """
  2. Author renyupeng
  3. coding=utf-8
  4. @Time : 2023/2/9 5:07 下午
  5. @Site :
  6. @File : PromoterInfoWebHook.py
  7. @Software: PyCharm
  8. @contact: renyupeng@c-top.com.cn
  9. @Tel 1501435553
  10. """
  11. import time
  12. from concurrent.futures.thread import ThreadPoolExecutor
  13. from flask import Flask, request, json
  14. from constant.ConfConstant import ConfConstant
  15. from spider.PromoterFansInfo import PromoterFansInfo
  16. from spider.PromoterInfoSpider import PromoterInfoSpider
  17. from spider.PromoterLiveInfoSpider import PromoterLiveInfoSpider
  18. from spider.PromoterVideoAnalysisInfo import PromoterVideoAnalysisInfo
  19. from spider.PromoterVideoAnalysisTrend import PromoterVideoAnalysisTrend
  20. app = Flask(__name__)
  21. def api_root():
  22. return 'Welcome guys'
  23. @app.route('/promoterInfo/getPromoterId', methods=['POST'])
  24. def webhook_get_promoter():
  25. rep = json.loads(request.data)
  26. promoterId = rep["promoterId"]
  27. pool = ThreadPoolExecutor(max_workers=10)
  28. result = PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId=promoterId)
  29. pool.submit(PromoterFansInfo().PromoterFansInfoHandler(promoterId=promoterId))
  30. pool.submit(PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId=promoterId))
  31. pool.submit(PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId=promoterId))
  32. pool.submit(PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId=promoterId))
  33. pool.shutdown()
  34. return result
  35. if __name__ == '__main__':
  36. app.run(port=9999, host=ConfConstant.URL, debug=True)