|
@@ -8,9 +8,11 @@ coding=utf-8
|
|
@contact: renyupeng@c-top.com.cn
|
|
@contact: renyupeng@c-top.com.cn
|
|
@Tel 1501435553
|
|
@Tel 1501435553
|
|
"""
|
|
"""
|
|
|
|
+import os
|
|
import random
|
|
import random
|
|
|
|
|
|
import redis
|
|
import redis
|
|
|
|
+import requests
|
|
from flask import Flask, request, json
|
|
from flask import Flask, request, json
|
|
|
|
|
|
from DouyinSpider.SpiderDouyinHeader import SpiderDouyinHeader
|
|
from DouyinSpider.SpiderDouyinHeader import SpiderDouyinHeader
|
|
@@ -23,6 +25,8 @@ from spider.PromoterVideoAnalysisTrend import PromoterVideoAnalysisTrend
|
|
from multiprocessing import Process
|
|
from multiprocessing import Process
|
|
|
|
|
|
from spider.ReturnPromoterInfoSpider import ReturnPromoterInfoSpider
|
|
from spider.ReturnPromoterInfoSpider import ReturnPromoterInfoSpider
|
|
|
|
+from utils.EtlFirstDeliveryValidMaterials import EtlFirstDeliveryValidMaterials
|
|
|
|
+from utils.UpLoadFile import UpLoadFile
|
|
from utils.cookie_update import cookie_update
|
|
from utils.cookie_update import cookie_update
|
|
from utils.douyin_cookie_update import douyin_cookie_update
|
|
from utils.douyin_cookie_update import douyin_cookie_update
|
|
|
|
|
|
@@ -49,7 +53,7 @@ def webhook_get_promoter():
|
|
cookie = random_item[0].decode('utf-8')
|
|
cookie = random_item[0].decode('utf-8')
|
|
phone_num = int(random_item[1])
|
|
phone_num = int(random_item[1])
|
|
roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
|
|
roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
|
|
- print(roll,'-----000-----{promoterId}'.format(promoterId=promoterId))
|
|
|
|
|
|
+ print(roll, '-----000-----{promoterId}'.format(promoterId=promoterId))
|
|
return roll
|
|
return roll
|
|
|
|
|
|
|
|
|
|
@@ -59,7 +63,7 @@ def webhook_get_promoter():
|
|
cookie = random_item[0].decode('utf-8')
|
|
cookie = random_item[0].decode('utf-8')
|
|
phone_num = int(random_item[1])
|
|
phone_num = int(random_item[1])
|
|
roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
|
|
roll = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, cookie)
|
|
- print(roll,'-----111-----{promoterId}'.format(promoterId=promoterId))
|
|
|
|
|
|
+ print(roll, '-----111-----{promoterId}'.format(promoterId=promoterId))
|
|
|
|
|
|
if json.loads(roll).__contains__("result"):
|
|
if json.loads(roll).__contains__("result"):
|
|
if json.loads(roll)["result"] == 109:
|
|
if json.loads(roll)["result"] == 109:
|
|
@@ -67,7 +71,7 @@ def webhook_get_promoter():
|
|
SendFeiShuMsg.send_cookie_robot_msg(
|
|
SendFeiShuMsg.send_cookie_robot_msg(
|
|
"cookie 永久失效 轻更新cookie 唯一电话为{phone_num}".format(phone_num=phone_num))
|
|
"cookie 永久失效 轻更新cookie 唯一电话为{phone_num}".format(phone_num=phone_num))
|
|
retry_item = cookie_update.r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
|
|
retry_item = cookie_update.r.zrange('kuaishou_shop_click_token', 0, -1, withscores=True)
|
|
- print(retry_item[0][0],'-----cookie-----')
|
|
|
|
|
|
+ print(retry_item[0][0], '-----cookie-----')
|
|
retry_cookie = retry_item[0][0].decode('utf-8')
|
|
retry_cookie = retry_item[0][0].decode('utf-8')
|
|
cookie_update.update_cookie_handler(phone_num)
|
|
cookie_update.update_cookie_handler(phone_num)
|
|
rollback = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
|
|
rollback = ReturnPromoterInfoSpider().PromoterInfoSpiderHandler(promoterId, retry_cookie)
|
|
@@ -84,7 +88,7 @@ def webhook_get_promoter():
|
|
p3.start()
|
|
p3.start()
|
|
p4.start()
|
|
p4.start()
|
|
p5.start()
|
|
p5.start()
|
|
- print(rollback,'--222---{promoterId}'.format(promoterId=promoterId))
|
|
|
|
|
|
+ print(rollback, '--222---{promoterId}'.format(promoterId=promoterId))
|
|
|
|
|
|
return rollback
|
|
return rollback
|
|
|
|
|
|
@@ -159,5 +163,51 @@ def webhook_update_promoter():
|
|
return '0'
|
|
return '0'
|
|
|
|
|
|
|
|
|
|
|
|
+@app.route('/webhook/get_file', methods=['POST'])
|
|
|
|
+def api_webhook_get_file():
|
|
|
|
+ payload = {}
|
|
|
|
+ headers = {
|
|
|
|
+ 'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
|
|
|
|
+ 'Accept': '*/*',
|
|
|
|
+ 'Host': 'api.tjyourong.com.cn',
|
|
|
|
+ 'Connection': 'keep-alive'
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if 'file' not in request.files:
|
|
|
|
+ url = "http://api.tjyourong.com.cn/jeecg-boot/first/delivery/excelCallBack?msg={msg}".format(msg='error')
|
|
|
|
+ response = requests.request("GET", url, headers=headers, data=payload)
|
|
|
|
+ print(response.text, 'error1')
|
|
|
|
+ return '200'
|
|
|
|
+ file = request.files['file']
|
|
|
|
+ if file.filename == '':
|
|
|
|
+ url = "http://api.tjyourong.com.cn/jeecg-boot/first/delivery/excelCallBack?msg={msg}".format(msg='error')
|
|
|
|
+ response = requests.request("GET", url, headers=headers, data=payload)
|
|
|
|
+ print(response.text, 'error2')
|
|
|
|
+ return '200'
|
|
|
|
+ try:
|
|
|
|
+ file.save('/home/excel/' + 'upload.csv')
|
|
|
|
+ status = UpLoadFile.uploadFile('upload.csv')
|
|
|
|
+ if status == 0:
|
|
|
|
+ url = "http://api.tjyourong.com.cn/jeecg-boot/first/delivery/excelCallBack?msg={msg}".format(msg='success')
|
|
|
|
+ requests.request("GET", url, headers=headers, data=payload)
|
|
|
|
+ else:
|
|
|
|
+ url = "http://api.tjyourong.com.cn/jeecg-boot/first/delivery/excelCallBack?msg={msg}".format(msg='error')
|
|
|
|
+ requests.request("GET", url, headers=headers, data=payload)
|
|
|
|
+ material_status = EtlFirstDeliveryValidMaterials().handler()
|
|
|
|
+ if material_status == 0:
|
|
|
|
+ url = "http://api.tjyourong.com.cn/jeecg-boot/first/delivery/excelCallBack?msg={msg}".format(msg='success')
|
|
|
|
+ requests.request("GET", url, headers=headers, data=payload)
|
|
|
|
+ else:
|
|
|
|
+ url = "http://api.tjyourong.com.cn/jeecg-boot/first/delivery/excelCallBack?msg={msg}".format(msg='error')
|
|
|
|
+ requests.request("GET", url, headers=headers, data=payload)
|
|
|
|
+ os.remove('/data/excel/' + 'upload.csv')
|
|
|
|
+ return '200'
|
|
|
|
+ except Exception as e:
|
|
|
|
+ url = "http://api.tjyourong.com.cn/jeecg-boot/first/delivery/excelCallBack?msg={msg}".format(msg='error')
|
|
|
|
+ response = requests.request("GET", url, headers=headers, data=payload)
|
|
|
|
+ print(response.text, 'error3')
|
|
|
|
+ return '200'
|
|
|
|
+
|
|
|
|
+
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
app.run(port=9999, host=ConfConstant.URL, debug=True)
|
|
app.run(port=9999, host=ConfConstant.URL, debug=True)
|