[ 웹 크롤링 ] 네이버 만화 크롤링 하기
2022. 4. 19. 20:40ㆍ웹 크롤링
package class06;
import java.io.IOException;
import java.util.Iterator;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class Test02 {
public static void main(String[] args) {
// 웹 페이지에서 샘플데이터 가져오기(네이버 웹툰명)
final String url="https://comic.naver.com/index";
Document doc=null;
try {
doc = Jsoup.connect(url).get();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// System.out.println(doc);
// Document는 수행 결과물로, Jsoup이 HTML 전체문서를 받아옴을 확인할 수 있다.
Elements eles=doc.select("div.genreRecomInfo2 > h6");
// h6.title == h6 요소중에서 class 이름이 title인 요소
// System.out.println(eles);
Iterator<Element> itr=eles.iterator();
while(itr.hasNext()) {
String str=itr.next().text(); // text만 출력
System.out.println(str.substring(10)); // 10칸 제외
// 샘플데이터 가공처리
}
}
}
'웹 크롤링' 카테고리의 다른 글
[ 웹 크롤링 ] 지니 뮤직 순위 크롤링 하기 (0) | 2022.05.24 |
---|---|
[ 웹 크롤링 ] 네이버 영화 순위 크롤링 하기 (0) | 2022.04.19 |
[ 웹 크롤링 ] 크롤링 테스트 기본 코드 (0) | 2022.04.19 |
[ 웹 크롤링 ] 웹 크롤링 개념 정리 (0) | 2022.01.27 |