JSoupを使用してhttp://dictionary.reference.com/browse/quickからコンテンツを取得しようとしています。そのページに行くと、彼らがデータを整理する方法は、クイックという単語の各「単語タイプ」(形容詞、動詞、名詞)を独自のセクションとして提示することであり、各セクションには1つ以上のリストが含まれていることがわかります定義。
物事をもう少し複雑にするために、各定義の各単語はさらに別の Dictionary.com ページへのリンクになっています。
quick
adjective
1. done, proceeding, or occurring with promptness or rapidity...
2. that is over or completed within a short interval of time
...
14. Archaic.
a. endowed with life
b. having a high degree of vigor, energy, ...
noun
1. living persons; the quick and the dead
2. the tender, sensitive flesh of the living body...
...
adverb
...
私がやりたいことは、次のように JSoup を使用して、単語の種類とそれぞれの定義を文字列のリストとして取得することです。
public class Metadata {
// Ex: "adjective", "noun", etc.
private String wordType;
// Ex: String #1: "1. done, proceeding, or occurring with promptness or rapidity..."
// String #2: "that is over or completed within a short interval of time..."
private List<String> definitions;
}
したがって、ページは実際には で構成され、List<Metadata>
各Metadata
要素は 1 つ以上の定義とペアになった単語タイプです。
非常に簡単な API 呼び出しを使用して、単語の種類のリストを見つけることができました。
// Contains 1 Element for each word type, like "adjective", "noun", etc.
Document doc = Jsoup.connect("http://dictionary.reference.com/browse/quick").get();
Elements wordTypes = doc.select("div.body div.pbk span.pg");
doc.select(...)
しかし、各Metadata
インスタンスを取得するために他に何が必要かを理解するのに苦労しています。