master
zhangshanxue 2022-03-04 16:02:42 +08:00
commit 4d71f770d4
2 changed files with 44 additions and 28 deletions

View File

@ -1,35 +1,16 @@
# -*- coding: utf-8 -*-
import json
import sys
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cdn.v20180606 import cdn_client, models
import requests
if sys.argv.__len__() == 2:
try:
path = sys.argv[1]
cred = credential.Credential("AKIDwhBYeT2LN8cqoa6ML2SbT5RVJq76pHSN", "f4C5h38vRhgPr2wZw2rPfeNpzsTord8M")
httpProfile = HttpProfile()
httpProfile.endpoint = "cdn.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = cdn_client.CdnClient(cred, "", clientProfile)
req = models.PurgePathCacheRequest()
params = {
"Paths": [ path ],
"FlushType": "flush"
}
req.from_json_string(json.dumps(params))
resp = client.PurgePathCache(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)
flashPath = sys.argv[1]
urlPath = "http://smi.51sfsy.com/mrj/cdnrefresh?nonce=1532319693&token=881d1b9844fb78c165dad28752d67eb8&dirs="
# path = urlPath + "'" + flashPath +"'"
path = urlPath + flashPath
print(path)
r = requests.get(url= path)
print(r.status_code)
print(r.text)
else:
print("params error!")

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
import json
import sys
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cdn.v20180606 import cdn_client, models
if sys.argv.__len__() == 2:
try:
path = sys.argv[1]
cred = credential.Credential("AKIDwhBYeT2LN8cqoa6ML2SbT5RVJq76pHSN", "f4C5h38vRhgPr2wZw2rPfeNpzsTord8M")
httpProfile = HttpProfile()
httpProfile.endpoint = "cdn.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = cdn_client.CdnClient(cred, "", clientProfile)
req = models.PurgePathCacheRequest()
params = {
"Paths": [ path ],
"FlushType": "flush"
}
req.from_json_string(json.dumps(params))
resp = client.PurgePathCache(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)
else:
print("params error!")