Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
未知のサイトのすべての段落の間にあるすべてのテキストを抽出したい (つまり、サイトの構造がわからない)。
これまでのところ、私は持っています:
Elements paragraphEmail = doc.select("p");
どこdoc = Jsoup.connect(url).get();
doc = Jsoup.connect(url).get();
for (Element e : paragraphEmail) { }
これを達成する方法は?
doc.select("p")すべての段落要素をコレクションとして提供しますElements。
doc.select("p")
Elements
for each ループを使用してテキストを取得します。
for(Element e : paragraphEmail){ System.out.println(e.text()); }
Jsoup クックブックと API リファレンスを参照して、Jsoup のメソッドに慣れることをお勧めします。
クックブック API リファレンス