All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hn.utils.ICPUtil Maven / Gradle / Ivy

There is a newer version: 1.0.18
Show newest version
package com.hn.utils;

import cn.hutool.http.HttpUtil;
import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;

import java.net.MalformedURLException;
import java.net.URL;

public class ICPUtil {

    private static final Log log = LogFactory.get();

    private static final String ICP_URL = "https://api.ooopn.com/icp/api.php?url=";

    /**
     *  查询备案信息
     * @param domainName 域名
     * @return result
     */
    public static String icp(String domainName) {
        if(domainName.startsWith("http")){
            try {
                URL url = new URL(domainName);
                domainName = url.getHost();
            } catch (MalformedURLException urlException) {
                throw new IllegalArgumentException("domainName 不符合规则");
            }
        }

        String result = HttpUtil.get(ICP_URL.concat(domainName));
        log.info("域名查询 返回结果:{}", result);
        return result;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy