Example #1
0
from qiniu import QiniuMacAuth, http
import requests, time

#  密钥队初始化
access_key = 'your_AK'
secret_key = 'your_SK'
q = QiniuMacAuth(access_key, secret_key)

url = 'http://ai.qiniuapi.com/v3/video/censor'   # 请求url
data = {"data": {"uri": "http://cdn.vcore.hk/1528336770927592712019-02-181550474493.mp4"}, "params": {"scenes": ["pulp", "terror", "politician"]}}
ret, info = http._post_with_qiniu_mac(url, data, q)
job = ret['job']

time.sleep(10)
# 根据job得到结果
url1 = 'http://ai.qiniuapi.com/v3/jobs/video/{}'.format(job)
token = "Qiniu " + q.token_of_request("GET", "ai.qiniuapi.com", url1, "")
r = requests.get(url1, headers={'Authorization': token})
print(r.text)


Example #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from qiniu import QiniuMacAuth
import os

import requests
import json

access_key = os.getenv('QINIU_ACCESS_KEY')
secret_key = os.getenv('QINIU_SECRET_KEY')

auth = QiniuMacAuth(access_key, secret_key)

url = "http://ai.qiniuapi.com/v1/face/group/oghfaogjdaovgjh/new"
body_url = [{"uri": "http://oggutrkz1.bkt.clouddn.com/345.png"}]
data = {"data": body_url}
token = auth.token_of_request(method='POST', url=url, body=json.dumps(data), content_type='application/json',
                              qheaders="", host="ai.qiniuapi.com")
header = {'Content-Type': 'application/json', 'Authorization': 'Qiniu %s' % token}
req = requests.post(url, headers=header, data=json.dumps(data))
print (req.text)
print (req.status_code)
print(req.headers)
Example #3
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from qiniu import QiniuMacAuth
from qiniu import http
import json
from configobj import ConfigObj

config = ConfigObj("../../.config.ini", encoding='UTF8')
# 读配置文件
access_key = config['account']['access_key']
secret_key = config['account']['secret_key']

q_auth = QiniuMacAuth(access_key, secret_key)
data_json = "{\"data\":{\"uri\":\"http://7xlv47.com1.z0.glb.clouddn.com/pulpsexy.jpg\"}" + "}"
url = "http://argus.atlab.ai/v1/pulp"
content_type = "application/json"
# data = data_json.encode('utf-8')
authorization = "Qiniu " + q_auth.token_of_request("POST", "argus.atlab.ai", url, "", content_type, data_json)
headers = {}
headers["Host"] = "argus.atlab.ai"
headers["Content-Type"] = content_type
ret, info = http._post_with_qiniu_mac(url, json.loads(data_json), q_auth)
print(info)
Example #4
0
import requests
import json
from qiniu import QiniuMacAuth

access_key = '3gFTmZm'
secret_key = 'aF3_h9AwDE'

#生成鉴权QiniuToken
auth = QiniuMacAuth(access_key, secret_key)
body = json.dumps({"data": {"uri": "http://"}})

url = "http://ai.qiniuapi.com/v1/ocr/idcard"
token = "Qiniu " + auth.token_of_request(
    method="POST", url=url, body=body, content_type="application/json")

header = {
    "Authorization": token,
    "Host": "ai.qiniuapi.com",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=header, data=body)
print(response.status_code, response.text)
Example #5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from qiniu import QiniuMacAuth
import os

import requests
import json

access_key = os.getenv('QINIU_ACCESS_KEY')
secret_key = os.getenv('QINIU_SECRET_KEY')

auth = QiniuMacAuth(access_key, secret_key)

url = "http://ai.qiniuapi.com/v1/face/detect"
data = {"data": {"uri": "http://oayjpradp.bkt.clouddn.com/Audrey_Hepburn.jpg"}}
# token = auth.token_of_request(method='POST', url=url, body=json.dumps(data), content_type='application/json',qheaders="", host="ai.qiniuapi.com")
token = auth.token_of_request('POST', url, json.dumps(data),
                              'application/json', '', "ai.qiniuapi.com")
header = {
    'Content-Type': 'application/json',
    'Authorization': 'Qiniu %s' % token
}

req = requests.post(url, headers=header, data=json.dumps(data))

print(req.text)
print(req.status_code)
print(req.headers)
Example #6
0
"""
接口文档:https://developer.qiniu.com/dora/manual/4438/face-recognition
显示所有的人像库
"""
import requests
from qiniu import QiniuMacAuth

with open('key.txt', 'r') as f1:
    keys = f1.readlines()

access_key = keys[0].strip('\n')
secret_key = keys[1].strip('\n')

#生成鉴权QiniuToken
auth = QiniuMacAuth(access_key, secret_key)

url = "http://ai.qiniuapi.com/v1/face/group"
token = "Qiniu " + auth.token_of_request(method="GET", url=url)

headers = {"Authorization": token, "Host": "ai.qiniuapi.com"}

response = requests.get(url, headers=headers)
print(response.status_code, response.text)