0
我使用java API來根據給定的URL提取第二個域名。Java api public-suffix-list返回一個空域
https://github.com/whois-server-list/public-suffix-list
它基於Mozilla的PUBLIC SUFFIX LIST
。
考慮下面的代碼:
PublicSuffixListFactory factory = new PublicSuffixListFactory();
PublicSuffixList suffixList = factory.build();
String[] domainArray = new String[10];
domainArray[0] = "swcdn.apple.com";
domainArray[1] = "production-pdt.siriusxm.com";
domainArray[2] = "audio2.spotify.com";
domainArray[3] = "a1935.phobos.apple.com";
domainArray[4] = "r13---sn-ab5l6n7r.c.pack.google.com";
domainArray[5] = "a132.phobos.apple.com";
domainArray[6] = "a1736.phobos.apple.com";
domainArray[7] = "r17---sn-vgqs7n7l.c.android.clients.google.com";
domainArray[8] = "s4.amazonaws.com";
domainArray[9] = "s3.amazonaws.com";
for(String string : domainArray){
String domain = suffixList.getRegistrableDomain(string);
System.out.println(domain);
}
我得到了以下的輸出:
apple.com
siriusxm.com
spotify.com
apple.com
google.com
apple.com
apple.com
google.com
amazonaws.com
null
它適用於大多數領域,但對於s3.amazonaws.com
,則返回null。但是對於類似的:s4.amazonaws.com
,它會給出正確的結果。有什麼問題?
登記?所以我們不能處理這樣的域名? – byteBiter 2014-11-14 19:19:46
如果您認爲s3.amazonaws.com不應該包含在該列表中,您可以要求Mozilla刪除該列表。 – 2014-11-14 20:11:05