크롤링 대상


전략
1] ul.section_list_ranking > li > a 의 구조
2] a tag에 title 속성에서 값을 get 하자
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
class Cwl {
String target_url;
Cwl() {
this.target_url = "https://news.naver.com/main/main.nhn?mode=LSD&mid=shm&sid1=101";
}
public void requestUrl() throws IOException {
Document doc = Jsoup.connect(this.target_url).get();
Element element = doc.selectFirst("ul.section_list_ranking");
Elements elements = element.select("li > a");
for (Element e : elements) {
System.out.println(e.attr("title"));
}
}
}
public class stu01 extends Cwl{
public static void main(String[] args) throws IOException {
Cwl cwl_object = new Cwl();
cwl_object.requestUrl();
} // end of main function
}
결과

'언어 > java' 카테고리의 다른 글
java + elasticsearch highlevel rest api (0) | 2020.07.04 |
---|---|
정올 1523 (9) (0) | 2020.05.06 |
정올 1338번문제 (8일차) (2) | 2020.05.03 |
1314 정올 (7-2) (0) | 2020.05.02 |
1307 정올 7일차 (0) | 2020.05.02 |
정올 1523 (9)
언어/java2020. 5. 6. 18:40
http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=795&sca=2020
JUNGOL | 별삼각형1 > 문제은행
삼각형의 높이 n과 종류 m을 입력받은 후 다음과 같은 삼각형 형태로 출력하는 프로그램을 작성하시오. 삼각형의 크기 n(n의 범위는 100 이하의 자연수)과 종류 m(m은 1부터 3사이의 자연수)을 입력받는다.
www.jungol.co.kr
class Triangle {
public int height;
public int kind_choice;
Triangle() {
this.height = 0;
this.kind_choice = 0;
}
public void kind1() {
// kind _1
for (int i = 1; i <= this.height; i++) {
// 높이
for (int j = 1; j <= i; j++) {
// 별
System.out.print("*");
}
System.out.println();
}
} // end of kind1 function
public void kind2() {
// kind _2
for (int i = 1; i <= this.height; i++) {
// 높이
for (int j = this.height; j >= i; j--) {
// 별
System.out.print("*");
}
System.out.println();
}
} // end of kind2 function
public void kind3() {
// kind _3
for (int i = 1; i <= this.height; i++) {
// 높이
for (int m = i; m < this.height; m++) {
// 공백
System.out.print(" ");
}
for (int j = 1; j <= 2*i-1; j++) {
// 별
System.out.print("*");
}
// 개행
System.out.println();
}
} // end of kind2 function
}
'언어 > java' 카테고리의 다른 글
java + elasticsearch highlevel rest api (0) | 2020.07.04 |
---|---|
java 크롤링 (0) | 2020.05.09 |
정올 1338번문제 (8일차) (2) | 2020.05.03 |
1314 정올 (7-2) (0) | 2020.05.02 |
1307 정올 7일차 (0) | 2020.05.02 |
정올 1338번문제 (8일차)
언어/java2020. 5. 3. 23:02
가장 않좋은 main 함수에 다 때려박기 코드 ㅋㅋㅋ
http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=2074&sca=20
JUNGOL | 문자삼각형1 > 문제은행
삼각형의 높이 N을 입력받아서 아래와 같이 문자 'A'부터 차례대로 왼쪽 대각선으로 채워서 삼각형 모양을 출력하는 프로그램을 작성하시오. < 처리조건 > (1) 오른쪽 위부터 왼쪽 아래쪽으로 이��
www.jungol.co.kr
import java.util.Scanner;
public class Jung1338 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
char [][] numArry;
int size = 0;
size = input.nextInt();
numArry= new char[size][size];
int n =0;
int m =size-1;
int s = (int)'A';
int tmp_n = 0;
int tmp_m = 0;
while (n != size) {
tmp_n = n;
tmp_m = m;
while (tmp_n != size) {
numArry[tmp_n][tmp_m] = (char) s;
tmp_n += 1;
tmp_m -= 1;
s += 1;
}
n += 1;
}
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
System.out.printf("%c", numArry[i][j]);
if ( j != size-1) {
System.out.print(" ");
}
}
System.out.println();
}
}
}
'언어 > java' 카테고리의 다른 글
java 크롤링 (0) | 2020.05.09 |
---|---|
정올 1523 (9) (0) | 2020.05.06 |
1314 정올 (7-2) (0) | 2020.05.02 |
1307 정올 7일차 (0) | 2020.05.02 |
정올 1430 (6일차) (0) | 2020.04.30 |