Commit d89eceac authored by Deokhyun Lee's avatar Deokhyun Lee

added NewsSearch & BlogSearch (just need to add the other two)

parent 7772f814
......@@ -12,17 +12,21 @@ public class Main {
NaverAPI nv = new NaverAPI();
String keyword = null;
int counter = 0;
String responseBody = null;
Scanner sc = new Scanner(System.in);
System.out.println("1. 뉴스 검색; 2. 블로그 검색; 3. 영화 검색; 4. 책 검색");
counter = sc.nextLine().toIn;
counter = Integer.parseInt(sc.nextLine());
System.out.print("Keyword를 말해주세요");
keyword = sc.nextLine();
// String responseBody = nv.searchBlog("놀러갈만한곳");
String responseBody = nv.searchNews("코로나");
System.out.println(responseBody);
if (counter == 1){
responseBody = nv.searchNews(keyword);
}else if (counter == 2){
responseBody = nv.searchBlog(keyword);
}
// json 파싱
Gson gson = new Gson();
JsonObject jsonObject = new Gson().fromJson(responseBody, JsonObject.class);
JsonArray jsonArray = jsonObject.getAsJsonArray("items");
for (JsonElement em : jsonArray) {
......
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