Angrily crawling a certain broken Hub site resources, just for this pornographic platform

Yellow is already something we cannot tolerate but cannot prevent, especially for content tools and platforms, so it took 30 minutes to build a pornographic platform and share it with everyone.

# data preparation

I found N many resources and couldn't solve the problem, so I furiously crawled a certain Bub data and prepared to verify the pornographic effect.

# Account preparation

This article uses UAI-Censor provided by UCloud. Currently, he supports pictures, and violent terrorist and political associations have been launched one after another. He provides 2,000 free calls per day, so it is enough for testing or niche tools.

1. Use the following link to register an account

https://urlify.cn/Bj2Y3y

2. Create UAI-Censor application

Obtain the application ID and use it when calling pornography API calls. After successful registration, enter the console, search for UAI, and then click AI content review

Angrily crawling a certain broken Hub site resources, just for this pornographic platform

 

Click Create Application, enter a custom application name, and click OK

Angrily crawling a certain broken Hub site resources, just for this pornographic platform

 

After you click OK, a successful pop-up box will be displayed, the highlighted part is your application ID, keep it for backup

Angrily crawling a certain broken Hub site resources, just for this pornographic platform

 

3. Obtain public key, private key, and application ID

I got it, but can't everyone do it? All need to register a public key and private key so that only you can use it. Click to enter the following link

https://console.ucloud.cn/uapi/apikey

Click show to view the public key and private key

Angrily crawling a certain broken Hub site resources, just for this pornographic platform

 

Here is everything is ready, only the east wind

4. Coding

Before coding, we can manually call the API to see the returned result

Angrily crawling a certain broken Hub site resources, just for this pornographic platform

 

As shown in the figure, after we enter the public key, private key and application ID, clicking on the verification will return a bunch of JSON. In fact, what we care about is the Porn’s Suggestion, pass-release, forbid-ban, check-manual review in the Result. Then the above test is the pass release. Wait, you don't believe it, do you? At this time, the resources of a certain Hub will come in handy, here is one.

I can’t bear to look straight, so I just typed, but did you see the forbid?

Angrily crawling a certain broken Hub site resources, just for this pornographic platform

 

Let's code it directly. The code is also very simple. The uaicensorPublicKey and uaicensorPrivateKey are your own, so I won't show them here, because the SpringBoot project is used, and RestTemplate is also very simple to use.

/**
     * @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<MultiValueMap<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;
    }

Is it very simple? So start your journey of discovery?

Guess you like

Origin blog.csdn.net/python8989/article/details/108502920