# -*- coding:utf-8 -*-
import requests
import json
import time
from general import getAntiContent
import random
import configparser
import MySQLdb
import os
accesstoken = ""
headers = {
"content-type": "application/json;charset=UTF-8",
"accesstoken": accesstoken,
"referer": "https://servicewechat.com/wxd9813e0a0d4d4156/49/page-frame.html",
"user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.17(0x17001124) NetType/WIFI Language/zh_CN",
"code-version": "0.0.43",
"verifyauthtoken": "",
"p-appname": "mobile-xcx-vegetable",
}
retry = 3
timeout = 20
provinceMap = {}
cf = configparser.ConfigParser()
try:
cf.read(os.getcwd() + "/conf.ini", encoding="utf-8-sig")
except Exception as e:
print("程序目录下不存在conf.ini配置文件~")
exit(0)
keywords = ""
try:
keywords = getConf("app-sys", "keywords").split(",")
except Exception as e:
print("keywords参数错误!")
exit(0)
# 启动时间点
startTime = getConf("app-sys", "start")
startTimes = []
try:
startTimes = startTime.split(",")
if startTimes is not None and len(startTimes) == 1 and startTimes[0] == "":
startTimes = []
except Exception as e:
pass
# 数据库账号
mysql_user = getConf("Mysql-Database", "user")
# 数据库密码
mysql_password = getConf("Mysql-Database", "password")
# 数据库名称
mysql_database = getConf("Mysql-Database", "database")
# 主机地址
mysql_host = getConf("Mysql-Database", "host")
# 端口
mysql_port = getConf("Mysql-Database", "port")
def querySQL(sql):
try:
conn = MySQLdb.connect(user=mysql_user, password=mysql_password, host=mysql_host, database=mysql_database, charset='utf8')
cursor = conn.cursor()
cursor.execute(sql)
return cursor.fetchall()
except Ex