Commit 7d95a5eb authored by Deokhyun Lee's avatar Deokhyun Lee

여러가지 해보는중

parents
Pipeline #2109 canceled with stages
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
/.idea/
/out/
/Crawling.iml
package melon;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Scanner;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class Main{
public static void main(String[] args) throws IOException {
// 멜로 100 차트
System.out.println("멜론 100 출력");
Scanner sc = new Scanner(System.in);
System.out.print("검색어: ");
String str = sc.next();
String text = URLEncoder.encode(str, "UTF-8");
String URL = "https://search.naver.com/search.naver?query=" + text + "&where=news&ie=utf8&sm=nws_hty";
Document doc = Jsoup.connect(URL).get();
Elements elem = doc.select("div[class=\"group_news\"]");
for (Element e : elem.select("a")) {
if (e.className().equals("news_tit")) {
System.out.println(e.text());
// continue;
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment