上篇文章:https://blog.csdn.net/hhaimm/article/details/124175679?spm=1001.2014.3001.5501
废话不多说,直接看代码
需要引入的包
from flask import Flask
from flask import request
import pymysql
import time
import re
from datetime import date, timedelta
import hashlib
from bs4 import BeautifulSoup
使用 flask
app = Flask(__name__)
if __name__ == '__main__':
try:
app.run(host='0.0.0.0')
except Exception as f:
print(f)
pass
创建一个主方法,用于接收参数
@app.route('/', methods=["POST"])
def get_tasks():
pass
结合前两步进行数据判断
@app.route('/', methods=["POST"])
def get_tasks():
if request.method == 'POST':
try:
wechat_data = request.form.get("data")
re_data = re.findall(r'var msgList = \'(.*)\';', wechat_data)
biz__ = str(re.findall(r'var __biz = "(.*)"', wechat_data)[0])[:-2]
get_weChat = get_weChat_name(biz__, conn)
name = get_weChat[0]['the_public']
if not name:
name = re.findall(r'var nickname = "(.*)".html', wechat_data)
print("当前公众号为:", name)
dict_data = re_data[0]
data = eval(dict_data)
time_out_count = 0
t = time.time() * 1000
if not data['list']:
return str(False)
except Exception as f:
print(f)
return str(False)
return str(True)
相关业务逻辑可自行添加