怒爬某破Hub站资源,只为撸这个鉴黄平台!
Java研发军团
共 3008字,需浏览 7分钟
· 2020-12-30
# 数据准备
# 账号准备
1、使用如下链接注册账号
2、创建 UAI-Censor 应用
![](https://filescdn.proginn.com/cb4bf82d819e6b891372fa93ae5625ca/4cda40ed3f704d600f891df208cdcf79.webp)
![](https://filescdn.proginn.com/95131c61d66e584d54b6445a30f5efd2/7357e745951a4871f1e106c3a4afec50.webp)
![](https://filescdn.proginn.com/612b7926e0963aaf63c551b0cb52aa39/6b92f269831990381839f2cae596c15c.webp)
3、获取公钥、私钥,应用ID
https://console.ucloud.cn/uapi/apikey
点击显示即可查看公钥私钥了
![](https://filescdn.proginn.com/76ea6db74b210c5cbcd821f903a966cc/fc4b16744fe367b0551ccac2a5754752.webp)
4、编码
实在不忍直视啊,我就打码了,不过看到 forbid了吗
![](https://filescdn.proginn.com/b7fa28b9d833613c3bdd8d5731030aae/24868d4efd09f0d816736a73abd9df0a.webp)
/**
* @param imageUrl
* @return pass-放行, forbid-封禁, check-人工审核
* @throws Exception
*/
public String check(String imageUrl) {
String ucloudUrl = "http://api.uai.ucloud.cn/v1/image/scan";
String appId = "uaicensor-rjmvogpx";
String uaicensorPublicKey = null;
String uaicensorPrivateKey = null;
//图片绝对路径
RestTemplate rest = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
/**
* 生成signature,首字母排序
*/
String timestamp = System.currentTimeMillis() + "";
SortedMap<Object, Object> packageParams = new TreeMap<>();
packageParams.put("PublicKey", uaicensorPublicKey);
packageParams.put("ResourceId", appId);
packageParams.put("Timestamp", timestamp);
packageParams.put("Url", imageUrl);
String signature = null;
try {
signature = UCloudUtil.createSign(packageParams, uaicensorPrivateKey);
} catch (Exception e) {
return null;
}
/**
* 参数
*/
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
param.add("Scenes", "porn");
param.add("Method", "url");
param.add("Url", imageUrl);
/**
* headers 参数
*/
headers.setContentType(MediaType.parseMediaType("multipart/form-data; charset=UTF-8"));
headers.set("PublicKey", uaicensorPublicKey);
headers.set("Signature", signature);
headers.set("ResourceId", appId);
headers.set("Timestamp", timestamp);
HttpEntity
String , Object>> httpEntity = new HttpEntity<>(param, headers);ResponseEntity<String> responseEntity = rest.exchange(ucloudUrl, HttpMethod.POST, httpEntity, String.class);
String body = responseEntity.getBody();
JSONObject jsonObject = JSON.parseObject(body);
if (jsonObject.getInteger("RetCode") == 0) {
String res = jsonObject.getJSONObject("Result").getJSONObject("Porn").getString("Suggestion");
return res;
}
return null;
}
获得原创整理:《第2版:互联网大厂面试题》
评论