PromoterInfoWebHook.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. from flask import Flask, request, json
  12. from constant.ConfConstant import ConfConstant
  13. from spider.PromoterFansInfo import PromoterFansInfo
  14. from spider.PromoterInfoSpider import PromoterInfoSpider
  15. from spider.PromoterLiveInfoSpider import PromoterLiveInfoSpider
  16. from spider.PromoterVideoAnalysisInfo import PromoterVideoAnalysisInfo
  17. from spider.PromoterVideoAnalysisTrend import PromoterVideoAnalysisTrend
  18. from multiprocessing import Process
  19. from spider.ReturnPromoterInfoSpider import ReturnPromoterInfoSpider
  20. from utils.mysql_utils import MysqlUtils
  21. app = Flask(__name__)
  22. def api_root():
  23. return 'Welcome guys'
  24. @app.route('/promoterInfo/getPromoterId', methods=['POST'])
  25. def webhook_get_promoter():
  26. rep = json.loads(request.data)
  27. promoterId = rep["promoterId"]
  28. sql = "select cookie from ruixuan.kuaishou_supply_chain_cookie"
  29. cookie = MysqlUtils().QueryOne(sql)[0]
  30. rollback = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
  31. p1 = Process(target=PromoterInfoSpider().PromoterInfoSpiderHandler, args=(promoterId, cookie))
  32. p2 = Process(target=PromoterFansInfo().PromoterFansInfoHandler, args=(promoterId, cookie))
  33. p3 = Process(target=PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander, args=(promoterId, cookie))
  34. p4 = Process(target=PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler, args=(promoterId, cookie))
  35. p5 = Process(target=PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler, args=(promoterId, cookie))
  36. p1.start()
  37. p2.start()
  38. p3.start()
  39. p4.start()
  40. p5.start()
  41. return rollback
  42. if __name__ == '__main__':
  43. app.run(port=9999, debug=True)