PromoterInfoWebHook.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 spider.PromoterFansInfo import PromoterFansInfo
  15. from spider.PromoterInfoSpider import PromoterInfoSpider
  16. from spider.PromoterLiveInfoSpider import PromoterLiveInfoSpider
  17. from spider.PromoterVideoAnalysisInfo import PromoterVideoAnalysisInfo
  18. from spider.PromoterVideoAnalysisTrend import PromoterVideoAnalysisTrend
  19. app = Flask(__name__)
  20. def api_root():
  21. return 'Welcome guys'
  22. @app.route('/promoterInfo/getPromoterId', methods=['POST'])
  23. def webhook_get_promoter():
  24. rep = json.loads(request.data)
  25. promoterId = rep["promoterId"]
  26. print(promoterId, '-----')
  27. pool = ThreadPoolExecutor(max_workers=10)
  28. print(time.time(),'----00-----')
  29. result = PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId=promoterId)
  30. pool.submit(PromoterFansInfo().PromoterFansInfoHandler(promoterId=promoterId))
  31. pool.submit(PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId=promoterId))
  32. pool.submit(PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId=promoterId))
  33. pool.submit(PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId=promoterId))
  34. pool.shutdown()
  35. return result
  36. if __name__ == '__main__':
  37. app.run(port=9999, host='127.0.0.1', debug=True)