일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- JSON
- swingx
- Ajax
- MySQL
- 전자정부프레임워크
- tomcat
- PHP
- jsr 296
- iBATIS
- 가우스
- sencha touch
- WebLogic
- ibsheet
- phonegap
- Eclipse
- Android
- GPS
- PLSQL
- MFC
- 선택적조인
- dock
- appspresso
- jQuery
- oracle
- node.js
- JDOM
- Spring
- Struts
- Google Map
- rowspan
Archives
- Today
- Total
Where The Streets Have No Name
jsoup을 이용해서 게시판 목록 추출 본문
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class Demo2 {
public static void main(String[] args) throws Exception {
Document doc = Jsoup.connect("http://mlbpark.donga.com/mbs/articleL.php?mbsC=bullpen&cpage=1").get();
System.out.println(doc.title());
Elements els = doc.getElementsByClass("G12read");
Elements els2 = doc.getElementsByClass("A11gray");
System.out.println("G12read: " + els.size()+"A11gray: "+els2.size());
for (int i=0;i < els.size();i++) {
Element el = els.get(i);
Element el2 = els2.get(i);
if(!el2.text().equals("공지")){
System.out.println(el2.text() + " - " + el.text());
Elements childs = el.getElementsByAttribute("href");
//System.out.println(childs.size());
if(childs.size() == 2){
//System.out.println(childs.get(0));
System.out.println("/mbs/articleVC.php?mbsC=bullpen&mbsIdx="+childs.get(0).attr("title"));
}
}
}
}
}