package com.teamdev.jxbrowser.chromium.demo.提取
域名;
import java.net.MalformedURLException;
@SuppressWarnings("unused")
public
class GetWebUrl {
public static String getUrl(String url) throws Exception{
java.net.URL urls = new java.net.URL(url);
String host = urls.getHost();// 获取主机名
return host;// 结果 blog.csdn.net
}
public static void main(String[] args) {
String url="https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1&tn=baidu&wd=java%20%E5%A6%82%E4%BD%95%E4%BF%9D%E7%95%99%E7%BD%91%E5%9D%80%E4%B8%AD%E7%9A%84%E5%9F%9F%E5%90%8D&rsv_pq=a836a1ee0003f627&rsv_t=611cx%2Bw1sCcJQ%2BydDYDlKIxj%2B9aNLXg%2B31Pkfj2kM6c0OhlP9LUnvvwcGwk&rqlang=cn&rsv_enter=1&rsv_sug3=68&rsv_sug1=8&rsv_sug7=101&rsv_sug2=0&inputT=24697&rsv_sug4=25423";
String domain="";
try {
domain = getUrl(url);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("domain="+domain);
}
}