This commit is contained in:
512song committed 2023-06-08 17:10:42 +08:00
1 parent da12135bd4
commit 94d6b1116a
5 files changed
+520 -215

No files matched your search

+162 -53
View File
@@ -10,12 +10,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 52,
"id": "dea5e486-6927-469f-aa57-e5efac4670be",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-31T05:19:09.972334Z",
"iopub.status.busy": "2023-05-31T05:19:09.971473Z",
"iopub.status.idle": "2023-05-31T05:19:10.054344Z",
"shell.execute_reply": "2023-05-31T05:19:10.053621Z",
"shell.execute_reply.started": "2023-05-31T05:19:09.972292Z"
},
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"source": [
"import openpyxl\n",
"import json\n",
@@ -240,15 +255,15 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 53,
"id": "c925d850-ff06-4be5-bf9f-31f4385c37c0",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-25T09:39:32.123643Z",
"iopub.status.busy": "2023-05-25T09:39:32.122802Z",
"iopub.status.idle": "2023-05-25T09:39:32.189169Z",
"shell.execute_reply": "2023-05-25T09:39:32.188132Z",
"shell.execute_reply.started": "2023-05-25T09:39:32.123602Z"
"iopub.execute_input": "2023-05-31T05:19:14.796522Z",
"iopub.status.busy": "2023-05-31T05:19:14.795763Z",
"iopub.status.idle": "2023-05-31T05:19:14.859923Z",
"shell.execute_reply": "2023-05-31T05:19:14.858869Z",
"shell.execute_reply.started": "2023-05-31T05:19:14.796492Z"
},
"tags": []
},
@@ -257,7 +272,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"162\n"
"163\n"
]
}
],
@@ -298,15 +313,15 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 54,
"id": "a87384c6-dc46-4d09-b757-b42462ed818d",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-25T09:51:28.611776Z",
"iopub.status.busy": "2023-05-25T09:51:28.610914Z",
"iopub.status.idle": "2023-05-25T09:51:28.626319Z",
"shell.execute_reply": "2023-05-25T09:51:28.625266Z",
"shell.execute_reply.started": "2023-05-25T09:51:28.611734Z"
"iopub.execute_input": "2023-05-31T05:19:18.950211Z",
"iopub.status.busy": "2023-05-31T05:19:18.949352Z",
"iopub.status.idle": "2023-05-31T05:19:18.965945Z",
"shell.execute_reply": "2023-05-31T05:19:18.964916Z",
"shell.execute_reply.started": "2023-05-31T05:19:18.950168Z"
},
"tags": []
},
@@ -315,8 +330,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"162\n",
"['6085', '5304', '3071', '8954', '4051', '2348', '7629', '3607', '2095', '8107', '7905', '2791', '8460', '5096', '4062', '1978', '0976', '8492', '0197', '0287', '3764', '6589', '5439', '5607', '0541', '8629', '3275', '7620', '4795', '3025', '5862', '5410', '1438', '2408', '2167', '1094', '4026', '3184', '9104', '7694', '1862', '7286', '6170', '6578', '6587', '5179', '2043', '4813', '2597', '3207', '6859', '8920', '1268', '4860', '9627', '2918', '3841', '4193', '9281', '7961', '3510', '6912', '4921', '7520', '8930', '8271', '2163', '3457', '8713', '1962', '7480', '4138', '2504', '7490', '7285', '4029', '2496', '4920', '3572', '9305', '7512', '6324', '5731', '4719', '6895', '4591', '0679', '5287', '3817', '4063', '2108', '9153', '2401', '2897', '6782', '3875', '8014', '4753', '2146', '2483', '5012', '5803', '9425', '3578', '5628', '9245', '4835', '7052', '8654', '3586', '1693', '3086', '7609', '3021', '1794', '2865', '1739', '7435', '4135', '5240', '0374', '6583', '0856', '0812', '5837', '7106', '0268', '8376', '5346', '0753', '4158', '1756', '2473', '6139', '3178', '7824', '3201', '6304', '6109', '0735', '8573', '9857', '3240', '5340', '0438', '7415', '2783', '3127', '5497', '8542', '9764', '6107', '9016', '0248', '2195', '5149', '7982', '4750', '4023', '9684', '0823', '0692']\n"
"164\n",
"['659821', '079384', '876923', '387406', '694158', '563974', '628540', '281407', '798056', '274185', '705316', '571698', '693240', '650329', '481397', '610492', '250746', '619873', '675018', '619204', '984351', '279548', '027154', '856432', '296138', '290486', '218396', '973605', '269043', '653487', '528397', '031947', '370415', '872591', '018592', '251794', '718203', '869254', '408517', '071948', '536729', '259430', '867310', '285413', '805216', '405192', '630721', '386219', '504216', '418752', '402398', '231947', '850743', '901378', '394175', '431092', '157489', '961378', '305921', '620417', '352906', '629380', '417086', '086149', '804693', '342580', '310827', '637102', '128635', '346780', '325076', '643917', '710548', '046732', '762390', '350712', '368419', '342701', '245107', '087136', '023185', '759846', '346758', '514976', '570482', '781935', '210987', '340615', '075891', '810596', '430689', '920785', '815347', '917562', '295817', '765238', '058479', '674159', '567894', '109842', '851943', '703918', '073489', '403958', '578492', '798046', '502876', '943180', '498306', '835760', '726305', '490867', '709413', '275683', '256934', '721830', '973841', '729685', '021349', '265413', '321597', '064187', '136794', '708352', '710928', '657129', '962105', '905436', '513749', '257361', '420691', '941567', '839574', '906358', '218095', '364152', '562149', '109823', '560942', '293561', '194053', '509246', '026951', '243561', '093154', '654083', '519048', '459136', '914362', '605834', '508693', '823906', '349725', '572390', '541236', '419570', '513467', '724063', '164823', '890712', '529840', '641958', '678590', '648951']\n"
]
}
],
@@ -331,8 +346,8 @@
"list1 = []\n",
"#print(code_num)\n",
"i = 1\n",
"while i < 163:\n",
" code = random.sample(code_list,4) #随机取6位数\n",
"while i < 165:\n",
" code = random.sample(code_list,6) #随机取6位数\n",
" code_num = ''.join(code)\n",
" if code_num not in list1:\n",
" list1.append(code_num)\n",
@@ -350,6 +365,52 @@
" json.dump(dict1, fl, ensure_ascii=False) "
]
},
{
"cell_type": "markdown",
"id": "6efc1c2b-7af1-49ec-9b48-8930a8dd2801",
"metadata": {},
"source": [
"## 生成下载链接"
]
},
{
"cell_type": "code",
"execution_count": 55,
"id": "10845b90-48b4-4418-9dac-dd4a6f0147c0",
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-31T05:19:22.535432Z",
"iopub.status.busy": "2023-05-31T05:19:22.534590Z",
"iopub.status.idle": "2023-05-31T05:19:22.546728Z",
"shell.execute_reply": "2023-05-31T05:19:22.545447Z",
"shell.execute_reply.started": "2023-05-31T05:19:22.535392Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"163\n"
]
}
],
"source": [
"filename = 'data/农业银行测试手机号码.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"dict2 = {}\n",
"for k, v in dict1.items():\n",
" dict2.setdefault(v['yzm'],{})\n",
" dict2[v['yzm']]['code'] = v['code']\n",
" dict2[v['yzm']]['name'] = v['name']\n",
"print(len(dict2))\n",
"filename = 'data/yzm.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict2, fl, ensure_ascii=False) \n"
]
},
{
"cell_type": "markdown",
"id": "fba0a0c4-edf2-45c2-9199-c6a86919f191",
@@ -398,63 +459,32 @@
"from tencentcloud.common import credential\n",
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
"from tencentcloud.sms.v20210111 import sms_client, models\n",
"\n",
"# 导入可选配置类\n",
"from tencentcloud.common.profile.client_profile import ClientProfile\n",
"from tencentcloud.common.profile.http_profile import HttpProfile\n",
"try: \n",
" secretId = \"AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc\"\n",
" secretKey = \"51XVL1YxDKI6mJh8au6DDuTskS1RhwJX\"\n",
" cred = credential.Credential(secretId, secretKey)\n",
" \n",
"\n",
" # 实例化一个http选项,可选的,没有特殊需求可以跳过。\n",
" cred = credential.Credential(secretId, secretKey) \n",
" httpProfile = HttpProfile()\n",
" # 如果需要指定proxy访问接口,可以按照如下方式初始化hp(无需要直接忽略)\n",
" # httpProfile = HttpProfile(proxy=\"http://用户名:密码@代理IP:代理端口\")\n",
" httpProfile.reqMethod = \"POST\" # post请求(默认为post请求)\n",
" httpProfile.reqTimeout = 30 # 请求超时时间,单位为秒(默认60秒)\n",
" httpProfile.endpoint = \"sms.tencentcloudapi.com\" # 指定接入地域域名(默认就近接入)\n",
"\n",
" # 非必要步骤:\n",
" # 实例化一个客户端配置对象,可以指定超时时间等配置\n",
" clientProfile = ClientProfile()\n",
" clientProfile.signMethod = \"TC3-HMAC-SHA256\" # 指定签名算法\n",
" clientProfile.language = \"en-US\"\n",
" clientProfile.httpProfile = httpProfile\n",
"\n",
" # 实例化要请求产品(以sms为例)的client对象\n",
" # 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,支持的地域列表参考 https://cloud.tencent.com/document/api/382/52071#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8\n",
" client = sms_client.SmsClient(cred, \"ap-guangzhou\", clientProfile)\n",
" req = models.SendSmsRequest()\n",
"\n",
" \n",
" # 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666\n",
" # 应用 ID 可前往 [短信控制台](https://console.cloud.tencent.com/smsv2/app-manage) 查看\n",
" req.SmsSdkAppId = \"1400140089\"\n",
" # 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名\n",
" # 签名信息可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-sign) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-sign) 的签名管理查看\n",
" req.SignName = \"坤铭教育\"\n",
" # 模板 ID: 必须填写已审核通过的模板 ID\n",
" # 模板 ID 可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-template) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-template) 的正文模板管理查看\n",
" req.TemplateId = \"1808914\"\n",
" # 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,,若无模板参数,则设置为空\n",
" req.TemplateId = \"1808914\" \n",
" req.TemplateParamSet = [\"1234\"]\n",
" # 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号]\n",
" # 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号\n",
" req.PhoneNumberSet = [\"+8613793180751\"]\n",
" # 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息,server 会原样返回\n",
" req.SessionContext = \"\"\n",
" # 短信码号扩展号(无需要可忽略): 默认未开通,如需开通请联系 [腾讯云短信小助手]\n",
" req.ExtendCode = \"\"\n",
" # 国内短信无需填写该项;国际/港澳台短信已申请独立 SenderId 需要填写该字段,默认使用公共 SenderId,无需填写该字段。注:月度使用量达到指定量级可申请独立 SenderId 使用,详情请联系 [腾讯云短信小助手](https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81)。\n",
" req.SenderId = \"\"\n",
"\n",
" resp = client.SendSms(req)\n",
"\n",
" # 输出json格式的字符串回包\n",
" print(resp.to_json_string(indent=2))\n",
"\n",
"except TencentCloudSDKException as err:\n",
" print(err)"
]
@@ -487,10 +517,89 @@
"print(dict1['SendStatusSet'][0][\"Message\"])"
]
},
{
"cell_type": "markdown",
"id": "c55a8af0-4e4d-4bd4-b5b1-0a7d9170958c",
"metadata": {},
"source": [
"## 批量发送短信(测试)"
]
},
{
"cell_type": "code",
"execution_count": 57,
"id": "910d1881-d090-48dc-ac87-685ccaaf9553",
"metadata": {
"execution": {
"iopub.execute_input": "2023-06-07T02:57:09.482569Z",
"iopub.status.busy": "2023-06-07T02:57:09.481698Z",
"iopub.status.idle": "2023-06-07T02:57:10.568979Z",
"shell.execute_reply": "2023-06-07T02:57:10.567913Z",
"shell.execute_reply.started": "2023-06-07T02:57:09.482528Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"亓宇航 send success\n",
"李伟丽 send success\n",
"高松 send success\n",
"张树伟 send success\n"
]
}
],
"source": [
"\n",
"from tencentcloud.common import credential\n",
"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\n",
"from tencentcloud.sms.v20210111 import sms_client, models\n",
"from tencentcloud.common.profile.client_profile import ClientProfile\n",
"from tencentcloud.common.profile.http_profile import HttpProfile\n",
"import json\n",
"\n",
"filename = 'data/短信测试手机号码.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl)\n",
"for k, v in dict1.items():\n",
" phone = '+86'+str(k)\n",
" yzm = v['yzm']\n",
" try: \n",
" secretId = \"AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc\"\n",
" secretKey = \"51XVL1YxDKI6mJh8au6DDuTskS1RhwJX\"\n",
" cred = credential.Credential(secretId, secretKey) \n",
" httpProfile = HttpProfile()\n",
" httpProfile.reqMethod = \"POST\" # post请求(默认为post请求)\n",
" httpProfile.reqTimeout = 30 # 请求超时时间,单位为秒(默认60秒)\n",
" httpProfile.endpoint = \"sms.tencentcloudapi.com\" # 指定接入地域域名(默认就近接入)\n",
" clientProfile = ClientProfile()\n",
" clientProfile.signMethod = \"TC3-HMAC-SHA256\" # 指定签名算法\n",
" clientProfile.language = \"en-US\"\n",
" clientProfile.httpProfile = httpProfile\n",
" client = sms_client.SmsClient(cred, \"ap-guangzhou\", clientProfile)\n",
" req = models.SendSmsRequest()\n",
" req.SmsSdkAppId = \"1400140089\"\n",
" req.SignName = \"坤铭教育\"\n",
" req.TemplateId = \"1808914\" \n",
" req.TemplateParamSet = [yzm]\n",
" req.PhoneNumberSet = [phone]\n",
" req.SessionContext = \"\"\n",
" req.ExtendCode = \"\"\n",
" req.SenderId = \"\"\n",
" resp = client.SendSms(req)\n",
" dict2 = json.loads(resp.to_json_string(indent=2))\n",
"\n",
" print(v['name'],dict2['SendStatusSet'][0][\"Message\"])\n",
" except TencentCloudSDKException as err:\n",
" print(v['name'],err)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "90242d3b-c719-4c23-a3e8-a718f86b14f3",
"id": "759cad53-8745-4862-8874-cf35f13ab0b3",
"metadata": {},
"outputs": [],
"source": []