일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- PLSQL
- Eclipse
- Spring
- jQuery
- Android
- 선택적조인
- Ajax
- jsr 296
- GPS
- node.js
- Google Map
- JSON
- dock
- 가우스
- WebLogic
- JDOM
- ibsheet
- 전자정부프레임워크
- MFC
- iBATIS
- phonegap
- swingx
- MySQL
- tomcat
- oracle
- sencha touch
- rowspan
- appspresso
- Struts
- PHP
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"));
}
}
}
}
}