You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.9 KiB
57 lines
1.9 KiB
|
10 months ago
|
import requests, json
|
||
|
|
import time
|
||
|
|
import hashlib
|
||
|
|
from ChaCeRndTrans import settings
|
||
|
|
|
||
|
|
|
||
|
|
# 发送短信接口
|
||
|
|
def send_msg(phone, content):
|
||
|
|
url = settings.URL
|
||
|
|
account = settings.ACCOUNT
|
||
|
|
pwd = settings.PWD
|
||
|
|
mttime = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
|
||
|
|
# import md5 #Python2里的引用
|
||
|
|
# s.encode()#变成bytes类型才能加密
|
||
|
|
m = hashlib.md5((pwd + mttime).encode())
|
||
|
|
md = m.hexdigest()
|
||
|
|
postData = "name=%s&pwd=%s&phone=%s&content=%s&mttime=%s&rpttype=1" % (account, md, phone, content, mttime)
|
||
|
|
|
||
|
|
headers = {
|
||
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||
|
|
'Cookie': 'secure'
|
||
|
|
}
|
||
|
|
response = requests.request("POST", url, headers=headers, data=postData.encode(encoding='UTF-8', errors='strict'))
|
||
|
|
# result = json.loads(response.text)
|
||
|
|
return response
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
mttime = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
|
||
|
|
print(mttime)
|
||
|
|
url = settings.URL
|
||
|
|
Account = settings.ACCOUNT
|
||
|
|
Pwd = settings.PWD
|
||
|
|
m = hashlib.md5((Pwd + mttime).encode())
|
||
|
|
md = m.hexdigest()
|
||
|
|
phone = '13580505142'
|
||
|
|
content = '【查策网】验证码:123456'
|
||
|
|
# params = u'{"name":"szccwl","pwd":"md","address":"bz","phone":"13000000000"}'
|
||
|
|
postData = "name=szccwl&pwd=%s&phone=%s&content=%s&mttime=%s&rpttype=1" % (md, phone, content, mttime)
|
||
|
|
# payload = 'name=szccwl&pwd=7e1ae2114ac4238d02e919a72b41026b&phone=18819470249&content=123456&mttime=20210106174609&rpttype=1'
|
||
|
|
headers = {
|
||
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||
|
|
'Cookie': 'secure'
|
||
|
|
}
|
||
|
|
|
||
|
|
response = requests.request("POST", url, headers=headers, data=postData.encode(encoding='UTF-8', errors='strict'))
|
||
|
|
|
||
|
|
print(response.text)
|
||
|
|
|
||
|
|
# r = requests.post(url, data=postData)
|
||
|
|
# key = json.loads(r.text)
|
||
|
|
# print(key)
|
||
|
|
# 这一步将返回值转成json
|
||
|
|
# key = json.loads(r.text)
|
||
|
|
# __business_id = uuid.uuid1()
|
||
|
|
# print(__business_id)
|