21 KiB
21 KiB
In [ ]:
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient["baogao"]
mycol = mydb["place"]
id = 199219
code = "09"
name = "党建出版社"
myquery = { "id": id }
num = mycol.count_documents(myquery)
if num>0:
print(num)
else:
mydict = { "id":id,"name": name, "code": code }
x = mycol.insert_one(mydict) In [ ]:
import openpyxl
import os,sys,shutil
import json
import math
import glob
import random
from pathlib import Path
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient["baogao"]
place_id = 199129
place_code = '09'
dw_name = '党建出版社'
fi_path = '/home/songyi/python/mycrm/flask/pdf/files'
fls = glob.glob(f'{fi_path}/{str(place_id)}/*.pdf')
code_list = []
for i in range(10): # 0~9
code_list.append(str(i))
list1 = []
i = 0
while i < len(fls):
code = random.sample(code_list,3) #随机取4位数
code_num = ''.join(code)
if place_code+code_num not in list1:
list1.append(place_code+code_num)
i +=1
i = 0
list2= []
for fn in fls:
dict2 = {}
fi_name =Path(fn).stem.split('-')[0]
#fi_name =Path(fn).stem
code = int(fi_name)
dxm = list1[i]
dict2 = {'place_id':place_id,'code':dxm,'fn':Path(fn).name}
list2.append(dict2)
i +=1
mycol = mydb["pdf"]
x = mycol.insert_many(list2)
print('ok')
In [ ]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient["baogao"]
mycol = mydb["pdf"]
filename = 'data/党建出版社人员信息.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
place_id = 199129
myquery = { "place_id": place_id }
for x in mycol.find(myquery,{ "_id": 0, "place_id": 0}):
code = int(x['fn'].split('-')[0])
if str(code) in dict1.keys():
dict2[code] = {'phone':str(dict1[str(code)]['phone']),'code':x['code'],'name':x['fn']}
else:
print('no phone')
#print(dict2)
i=1
#dict2 = {375: {'phone': '13793180751', 'code': '0379208'}}
for k, v in dict2.items():
phone = '+86'+v['phone']
yzm = v['code']
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendSmsRequest()
req.SmsSdkAppId = "1400140089"
req.SignName = "坤铭教育"
req.TemplateId = "1875765"
req.TemplateParamSet = ["党建读物出版社",yzm]
req.PhoneNumberSet = [phone]
req.SessionContext = ""
req.ExtendCode = ""
req.SenderId = ""
#resp = client.SendSms(req)
#dict3 = json.loads(resp.to_json_string(indent=2))
#print(v['phone'],dict3['SendStatusSet'][0]["Message"])
print(i,v['phone'],v['name'],)
i+=1
except TencentCloudSDKException as err:
print(v['phone'],err)In [7]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient["baogao"]
mycol = mydb["pdf"]
filename = 'data/党建出版社人员信息.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
place_id = 199129
myquery = { "place_id": place_id }
for x in mycol.find(myquery,{ "_id": 0, "place_id": 0}):
code = int(x['fn'].split('-')[0])
if str(code) in dict1.keys():
dict2[code] = {'phone':str(dict1[str(code)]['phone']),'code':x['code'],'name':x['fn']}
else:
print('no phone')
#print(dict2)
#dict2 = {375: {'phone': '13793180751', 'code': '0379208'}}
for k, v in dict2.items():
phone = '+86'+v['phone']
yzm = v['code']
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendSmsRequest()
req.SmsSdkAppId = "1400140089"
req.SignName = "坤铭教育"
req.TemplateId = "1875765"
req.TemplateParamSet = ["党建读物出版社测试者",yzm]
req.PhoneNumberSet = [phone]
req.SessionContext = ""
req.ExtendCode = ""
req.SenderId = ""
resp = client.SendSms(req)
dict3 = json.loads(resp.to_json_string(indent=2))
print(v['phone'],dict3['SendStatusSet'][0]["Message"])
except TencentCloudSDKException as err:
print(v['phone'],err)13121785820 send success 13720086744 send success 13693656695 send success 13426186396 send success 13501057678 send success 13161875896 send success 13501012920 send success 13811853310 send success 18611638796 send success 18810678896 send success 13699186853 send success 13521292627 send success 13041103013 send success 18611898178 send success 18910157525 send success 13241806918 send success 13521355217 send success 13501352062 send success 18910703015 send success 13911857566 send success 15201164833 send success 13521128277 send success 18301676593 send success 18612019322 send success 15201659775 send success 13691138025 send success 17310265675 send success 15321880277 send success 13911065115 send success 18910918208 send success 13811054320 send success 15810125280 send success 18731333343 send success 13051007911 send success 13661384033 send success 13501374160 send success 13021281605 send success 15201146624 send success 18331390853 send success 13501291562 send success 13810369127 send success 13501223612 send success 13810309913 send success 13321129123 send success 17610102287 send success 15910528892 send success 17600943891 send success 13501244543 send success 13466366688 send success 13810771996 send success 15028372357 send success 15210986716 send success 15210596709 send success 13511011065 send success 13161243312 send success 13811930436 send success 18601212064 send success 17777876076 send success 18910079573 send success 13681015505 send success 13501295167 send success 13401046976 send success 15600573826 send success 13661391588 send success 13621194207 send success 13581571058 send success 18612673197 send success 13501077447 send success 13426107286 send success 15201311223 send success 13366306271 send success 13683662162 send success 13911251027 send success 13520746787 send success 13691239288 send success 13661387440 send success 18519020871 send success 13120002157 send success 13581684332 send success 13810981957 send success 15911001918 send success 13439439129 send success
In [ ]:
dict1 = json.loads(resp.to_json_string(indent=2))
print(dict1['SendStatusSet'][0]["Message"])In [ ]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
import pymongo
phone = '+86'+'13793180751'
yzm = '09271'
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendSmsRequest()
req.SmsSdkAppId = "1400140089"
req.SignName = "坤铭教育"
req.TemplateId = "1875765"
req.TemplateParamSet = ["党建读物出版社测试者",yzm]
req.PhoneNumberSet = [phone]
req.SessionContext = ""
req.ExtendCode = ""
req.SenderId = ""
resp = client.SendSms(req)
dict3 = json.loads(resp.to_json_string(indent=2))
print(phone,dict3['SendStatusSet'][0]["Message"])
except TencentCloudSDKException as err:
print(v['phone'],err)In [ ]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient["baogao"]
mycol = mydb["pdf"]
filename = 'data/世纪花园人员信息.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
place_id = 624770
myquery = { "place_id": place_id,"code":"051067" }
for x in mycol.find(myquery,{ "_id": 0, "place_id": 0}):
code = int(x['fn'].split('-')[0])
if str(code) in dict1.keys():
dict2[code] = {'phone':str(dict1[str(code)]['phone']),'code':x['code']}
else:
print('no phone')
print(dict2)In [ ]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
import pymongo
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendStatusStatisticsRequest()
req.SmsSdkAppId = "1400140089"
# 拉取最大条数,最多100条
req.Limit = 100
# 偏移量 注:目前固定设置为0
req.Offset = 0
# 开始时间,yyyymmddhh 需要拉取的起始时间,精确到小时
req.BeginTime = "2023112700"
# 结束时间,yyyymmddhh 需要拉取的截止时间,精确到小时
# 注:EndTime 必须大于 BeginTime
req.EndTime = "2023112723"
# 通过client对象调用SendStatusStatistics方法发起请求。注意请求方法名与请求对象是对应的。
# 返回的resp是一个SendStatusStatisticsResponse类的实例,与请求对象对应。
resp = client.SendStatusStatistics(req)
# 输出json格式的字符串回包
print(resp.to_json_string(indent=2))
except TencentCloudSDKException as err:
print(err)
In [ ]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 60 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.PullSmsSendStatusRequest()
req.SmsSdkAppId = "1400140089"
req.Limit = 100
resp = client.PullSmsSendStatus(req)
# 输出json格式的字符串回包
print(resp.to_json_string(indent=2))
except TencentCloudSDKException as err:
print(err)
In [ ]: