""" Author renyupeng coding=utf-8 @Time : 2023/2/9 5:07 下午 @Site : @File : PromoterInfoWebHook.py @Software: PyCharm @contact: renyupeng@c-top.com.cn @Tel 1501435553 """ import time from concurrent.futures.thread import ThreadPoolExecutor from flask import Flask, request, json from spider.PromoterFansInfo import PromoterFansInfo from spider.PromoterInfoSpider import PromoterInfoSpider from spider.PromoterLiveInfoSpider import PromoterLiveInfoSpider from spider.PromoterVideoAnalysisInfo import PromoterVideoAnalysisInfo from spider.PromoterVideoAnalysisTrend import PromoterVideoAnalysisTrend app = Flask(__name__) def api_root(): return 'Welcome guys' @app.route('/promoterInfo/getPromoterId', methods=['POST']) def webhook_get_promoter(): rep = json.loads(request.data) promoterId = rep["promoterId"] print(promoterId, '-----') pool = ThreadPoolExecutor(max_workers=10) print(time.time(),'----00-----') result = PromoterInfoSpider().PromoterInfoSpiderHandler(promoterId=promoterId) pool.submit(PromoterFansInfo().PromoterFansInfoHandler(promoterId=promoterId)) pool.submit(PromoterLiveInfoSpider().PromoterLiveInfoSpiderHander(promoterId=promoterId)) pool.submit(PromoterVideoAnalysisInfo().PromoterVideoAnalysisInfoHandler(promoterId=promoterId)) pool.submit(PromoterVideoAnalysisTrend().PromoterVideoAnalysisTrendHandler(promoterId=promoterId)) pool.shutdown() return result if __name__ == '__main__': app.run(port=9999, host='127.0.0.1', debug=True)