ジェリコのようなHTMLパーサーが必要だと思います。
は、この例を見てみましょう: http://jericho.htmlparser.net/samples/console/src/ExtractText.java
特別にこの二つの方法:
private static String getTitle(Source source) {
Element titleElement=source.getFirstElement(HTMLElementName.TITLE);
if (titleElement==null) return null;
// TITLE element never contains other tags so just decode it collapsing whitespace:
return CharacterReference.decodeCollapseWhiteSpace(titleElement.getContent());
}
private static String getMetaValue(Source source, String key) {
for (int pos=0; pos<source.length();) {
StartTag startTag=source.getNextStartTag(pos,"name",key,false);
if (startTag==null) return null;
if (startTag.getName()==HTMLElementName.META)
return startTag.getAttributeValue("content"); // Attribute values are automatically decoded
pos=startTag.getEnd();
}
return null;
}
URLのタイトルと説明は何ですか?指定されたURLにあるHTMLページのタイトルですか?もしそうなら、その説明は何ですか?それはどこにありますか? –
ええ、htmlのWebページのタイトル、メタタグからのHTMLページの説明... –
あなたは解決策を見つけましたか? – jordeu