forked from eugenejade/JavaTPCProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject02_B.java
More file actions
64 lines (53 loc) · 2.15 KB
/
Project02_B.java
File metadata and controls
64 lines (53 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.io.*;
import org.jsoup.Jsoup;
import org.jsoup.nodes.*;
import org.jsoup.select.Elements;
import kr.inflearn.DownloadBroker;
public class Project02_B {
public static void main(String[] args) {
String url="https://sum.su.or.kr:8888/bible/today/Ajax/Bible/BosyMatter?qt_ty=QT1";
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try {
System.out.print("[입력->년(yyyy)-월(mm)-일(dd)]:");
String bible=br.readLine();
url=url+"&Base_de="+bible+"&bibleType=1";
System.out.println("================================");
Document doc=Jsoup.connect(url).post();
Element bible_text=doc.select(".bible_text").first();
System.out.println(bible_text.text());
Element bibleinfo_box=doc.select(".bibleinfo_box").first();
System.out.println(bibleinfo_box.text());
Elements liList=doc.select(".body_list > li");
for(Element li : liList) {
System.out.print(li.select(".num").first().text()+":");
System.out.println(li.select(".info").first().text());
}
// 리소스 다운로드(mp3, image)
/*
Element tag=doc.select("source").first();
String dPath=tag.attr("src").trim();
System.out.println(dPath); // http://meditation.su.or.kr/meditation_mp3/2019/20191010.mp3
String fileName=dPath.substring(dPath.lastIndexOf("/")+1);
*/
Element tag=doc.select(".img > img").first();
String dPath="https://sum.su.or.kr:8888"+tag.attr("src").trim();
System.out.println(dPath); // https://sum.su.or.kr:8888/attach/X07/2c06c62f3695489a8ff525a6ed138395.jpg
String fileName=dPath.substring(dPath.lastIndexOf("/")+1);
Runnable r=new DownloadBroker(dPath, fileName);
Thread dLoad=new Thread(r);
dLoad.start();
for(int i=0; i<10;i++) {
try {
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
System.out.print(""+(i+1));
}
System.out.println();
System.out.println("===============================");
} catch (Exception e) {
e.printStackTrace();
}
}
}