#37 java: jsoup api ex
This commit is contained in:
@@ -10,6 +10,8 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.jsoup:jsoup:1.16.1'
|
||||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
|
||||
}
|
||||
|
||||
37
java/api/src/main/java/jsoup/JsoupEx.java
Normal file
37
java/api/src/main/java/jsoup/JsoupEx.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package jsoup;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class JsoupEx {
|
||||
|
||||
public static void main(String[] args) {
|
||||
final String url = "https://sum.su.or.kr:8888/bible/today?base_de=2023-05-22";
|
||||
|
||||
Document document = null;
|
||||
try {
|
||||
document = Jsoup.connect(url).get();
|
||||
|
||||
Element bibleText = document.getElementById("bible_text");
|
||||
Element bibleInfoBox = document.getElementById("bibleinfo_box");
|
||||
|
||||
System.out.println("bibleText = " + bibleText.text());
|
||||
System.out.println("bibleInfoBox = " + bibleInfoBox.text());
|
||||
|
||||
Elements num = document.select(".num");
|
||||
Elements info = document.select(".info");
|
||||
|
||||
for (int i = 0; i < num.size(); i++) {
|
||||
System.out.println(num.get(i).text() + " : " + info.get(i).text());
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user