지구정복

[JAVA] 12/04 | DAO/DTO를 이용한 우편번호검색 프로그램, 네트워크기초(기본개념, 특정url 크롤링, TCP네트워킹), TCP네트워크를 이용한 구구단 출력 본문

데이터 엔지니어링 정복/JAVA & JSP

[JAVA] 12/04 | DAO/DTO를 이용한 우편번호검색 프로그램, 네트워크기초(기본개념, 특정url 크롤링, TCP네트워킹), TCP네트워크를 이용한 구구단 출력

eeaarrtthh 2020. 12. 4. 18:05
728x90
반응형

복습

CRUD - 어플리케이션(DML)
java program
	JDBC APIs
		java.sql.*
			Connection
			Statement / PrepaedStatement
			ResultSet
			* DatabaseMetaData / ResultSetMetaData
		JDBC driver
			각 데이터베이스 제작업체(벤더)
				mariadb - mariadb 사이트
				mysql, oracle - oracle 사이트
				msssql - microsoft 사이트
			DBMS

전 포스트에서 했던 우편번호 검색기의 강사님 코드는 아래와 같다.

package SearchZipcode;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class SearchZipcode3 {
	
	//동 이름 입력받는 메소드
	public String inputDong() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));;
		
		System.out.printf("동이름 입력: ");
		String strDong = br.readLine();
		if( br != null ) { br.close(); }
		return strDong;	
	}
	
	//동이름 검색해서 출력하는 메소드
	public ArrayList<String> searchDong (String strDong) throws ClassNotFoundException, SQLException {
		String url = "jdbc:mysql://localhost:3307/sample";
		String user = "root";
		String password = "!123456";
		
		Class.forName("org.mariadb.jdbc.Driver");
		Connection conn = DriverManager.getConnection(url, user, password);
		
		String sql = 
		"select zipcode, sido, gugun, dong, ri, bunji from zipcode where dong like ?";
		PreparedStatement pstmt = conn.prepareStatement(sql);
		pstmt.setString(1, strDong+"%");
		ResultSet rs = pstmt.executeQuery();
		
		ArrayList<String> datas = new ArrayList<String>();
		while( rs.next() ) {
			//System.out.println( rs.getString("zipcode") );
			String data = String.format("[%s] %s %s %s %s %s",
					rs.getString("zipcode"), rs.getString("sido"), rs.getString("gugun"),
					rs.getString("dong"), rs.getString("ri"), rs.getString("bunji"));
			datas.add( data );
		}
		
		if( rs != null ) rs.close();
		if( pstmt != null ) pstmt.close();
		if( conn != null ) conn.close();
		
		return datas;
	}
	
	public static void main(String[] args) {
		
		//메소드 호출
		SearchZipcode3 sz = new SearchZipcode3();
		
		try {
			String strDong = sz.inputDong();
			
			ArrayList<String> datas = sz.searchDong( strDong );
			for( String data : datas ) {
				System.out.println(data);
			}
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

 


DAO / DTO

-DAO(Data Access Object) : Database의 data에 접근을 위한 객체이다. 

웹서버는 DB와 연결하기 위해 매번 커넥션 객체를 생성하는데,

이것을 해결하기 위해 나온 것이 컨넥션 풀이다.

하지만 유저 한 명이 접속해서 한 번에 하나의 커넥션만 사용하지 않고 많은 커넥션을 일으키기 때문에 커넥션풀은 커넥션을 만드는 오버헤드를 효율적으로 하기 위해 DB에 접속하는 객체를 전용으로 하나만 만들고, 모든 페이지에서 그 객체를 호출해서 사용하게 된다.

이렇게 커넥션을 하나만 가져오고 그 커넥션을 가져온 객체가 모든 DB와 연결하는 것이 DAO 객체이다.

ConnectionPool이란 connection 객체를 미리 만들어 놓고 그것을 가져다 사용하는 것이다.

 

즉, DAO는 DB를 사용해 데이터를 조회하거나 조작하는 기능을 전담하도록 만든 오브젝트이다.

사용자는 자신이 필요한 Interface를 DAO에게 전달하고 DAO는 이 인터페이스를 구현한 객체를

사용자에게 편리하게 사용할 수 있도록 반환해준다.

  

-DTO(Data Transfer Object) : VO(Value Object)로 바꿔 말할 수 있는데 계층간 데이터 교환을 위한

 자바빈즈(beans)를 말한다. 여기서 말하는 계층간의 Controller, View, Business Layer, Persistent Later를 말하며 각 계층간 데이터 교환을 위한 객체를 DTO 또는 VO라고 부른다.

그런데 VO는 DTO와 동일한 개념이지만 read only 속성을 가진다.

 

일반적인 DTO는 로직을 갖고 있지 않는 순수한 데이터 객체이며 속성과 그 속성에 접근하기 위한

getter, setter 메소드만 가진 클래스를 말합니다.

 

실행클래스			->     DAO(실행객체)
		<- DTO(전달객체)  ->			메서드
        
        
--우편번호 예제에 적용해보자.

SearchZipcode4   - 실행클래스
ZipcodeTO	- DTO
ZipcodeDAO	- DAo

메인클래스에서 출력이나 모든 기능을 처리하지말고 클래스화해서 처리해야한다.

 

DAO / DTO를 우편번호 검색기에 적용해보자.

// ZipcodeTO
package SearchZipcode;

public class ZipcodeTO {
	// table의 컬럼과 1대1 매핑되거나
	// select문의 컬럼과 1대1 매핑이 되어야 데이터를 넣을 수 있다.
	private String zipcode;
	private String sido;
	private String gugun;
	private String dong;
	private String ri;
	private String bunji;
	private String seq;
	
	//생성자이면서 Setter
	public ZipcodeTO(String zipcode, String sido, String gugun, String dong, String ri, String bunji, String seq) {
		this.zipcode = zipcode;
		this.sido = sido;
		this.gugun = gugun;
		this.dong = dong;
		this.ri = ri;
		this.bunji = bunji;
		this.seq = seq;
	}
	
	//Getter
	public String getZipcode() {
		return zipcode;
	}

	public String getSido() {
		return sido;
	}

	public String getGugun() {
		return gugun;
	}

	public String getDong() {
		return dong;
	}

	public String getRi() {
		return ri;
	}

	public String getBunji() {
		return bunji;
	}

	public String getSeq() {
		return seq;
	}	
}
//ZipcodeDAO

package SearchZipcode;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class ZipcodeDAO {
	private Connection conn = null;
	//생성자이면서 데이터베이스 접속
	public ZipcodeDAO() throws ClassNotFoundException, SQLException {
		String url = "jdbc:mysql://localhost:3307/sample";
		String user = "root";
		String password = "!123456";
		
		Class.forName("org.mariadb.jdbc.Driver");
		this.conn = DriverManager.getConnection(url, user, password);
	}
	
	//sql 구문별 메서드
	public ArrayList<ZipcodeTO> serachZipcode(String strDong) throws ClassNotFoundException, SQLException {
		ArrayList<ZipcodeTO> datas = new ArrayList<ZipcodeTO>();
		
		String sql = 
		  "select zipcode, sido, gugun, dong, ri, bunji, seq from zipcode where dong like ?";
		PreparedStatement pstmt = this.conn.prepareStatement(sql);
		pstmt.setString(1, strDong+"%");
		ResultSet rs = pstmt.executeQuery();
		while( rs.next() ) {
			String zipcode = rs.getString("zipcode");
			String sido = rs.getString("sido");
			String gugun = rs.getString("gugun");
			String dong = rs.getString("dong");
			String ri = rs.getString("ri");
			String bunji = rs.getString("bunji");
			String seq = rs.getString("seq");
			ZipcodeTO to = new ZipcodeTO(zipcode, sido, gugun, dong, ri, bunji, seq);
			datas.add( to );
		}
		
		if( rs != null ) rs.close();
		if( pstmt != null ) pstmt.close();
		if( conn != null ) conn.close();
		
		return datas;
	}
}
//실행클래스

package SearchZipcode;

import java.sql.SQLException;
import java.util.ArrayList;

public class SearchZipcode4 {
	
	public static void main(String[] args) {
		try {
			ZipcodeDAO dao = new ZipcodeDAO();
			ArrayList<ZipcodeTO> datas = dao.serachZipcode("신사");
			
			for( ZipcodeTO to : datas ) {
				System.out.printf( to.getZipcode() );
				System.out.printf( to.getSido() +"\n");
			}
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

 

 

부서번호를 조회해서 사원정보를 출력

새로운 프로젝트를 만들고 아래 클래스들을 만들어서 실행시킨다.

SearchEmpEx01 - 실행클래스

EmpTO            - DTO

EmpDAO         - DAO

//EmpTO

package SearchEmpEx;

public class EmpTO {
	private String empno;
	private String ename;
	private String job;
	private String mgr;
	private String hiredate;
	private String sal;
	private String comm;
	private String deptno;
	
	public EmpTO(String empno, String ename, String job, String mgr, String hiredate, String sal, String comm,
			String deptno) {
		this.empno = empno;
		this.ename = ename;
		this.job = job;
		this.mgr = mgr;
		this.hiredate = hiredate;
		this.sal = sal;
		this.comm = comm;
		this.deptno = deptno;
	}

	public String getEmpno() {
		return empno;
	}

	public String getEname() {
		return ename;
	}

	public String getJob() {
		return job;
	}

	public String getMgr() {
		return mgr;
	}

	public String getHiredate() {
		return hiredate;
	}

	public String getSal() {
		return sal;
	}

	public String getComm() {
		return comm;
	}

	public String getDeptno() {
		return deptno;
	}
}
//EmpDAO

package SearchEmpEx;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class EmpDAO {
	private Connection conn = null;
	
	public EmpDAO() throws ClassNotFoundException, SQLException {
		String url = "jdbc:mysql://localhost:3307/sample";
		String user = "root";
		String password = "!123456";
		
		Class.forName("org.mariadb.jdbc.Driver");
		this.conn = DriverManager.getConnection(url, user, password);
	}
	
	public ArrayList<EmpTO> searchEmp(String strDeptno) throws ClassNotFoundException, SQLException {
		ArrayList<EmpTO> datas = new ArrayList<EmpTO>();
		
		String sql = 
		"select empno, ename, job, ifnull(mgr,0) mgr, hiredate, sal, ifnull(comm, 0) comm, deptno from emp where deptno = ?";
		PreparedStatement pstmt = this.conn.prepareStatement(sql);
		pstmt.setString(1, strDeptno);
		ResultSet rs = pstmt.executeQuery();
		while( rs.next() ) {
			String empno = rs.getString("empno");
			String ename = rs.getString("ename");
			String job = rs.getString("job");
			String mgr = rs.getString("mgr");
			String hiredate = rs.getString("hiredate");
			String sal = rs.getString("sal");
			String comm = rs.getString("comm");
			String deptno = rs.getString("deptno");
			EmpTO to = new EmpTO(empno, ename, job, mgr, hiredate, sal, comm, deptno);
			datas.add(to);
		}
		
		if( conn != null ) conn.close();
		if( pstmt != null ) pstmt.close();
		if( rs != null ) rs.close();
		
		return datas;
	}
}
//실행클래스

package SearchEmpEx;

import java.sql.SQLException;
import java.util.ArrayList;

public class SearchEmpEx01 {

	public static void main(String[] args) {
		try {
			EmpDAO dao = new EmpDAO();
			ArrayList<EmpTO> datas = dao.searchEmp("30");
			
			for( EmpTO to : datas ) {
				System.out.printf(to.getEmpno() + " ");
				System.out.printf(to.getEname() + " ");
				System.out.printf(to.getJob() + " ");
				System.out.printf(to.getMgr() + " ");
				System.out.printf(to.getHiredate() + " ");
				System.out.printf(to.getSal() + " ");
				System.out.printf(to.getComm() + " ");
				System.out.printf(to.getDeptno() + "\n");
			}
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

 

18.6 네트워크 기초

네트워크
1. 웹서버에 접속하는 방법
	=> 브라우저와 비슷한 역할
	=> url로 요청했을 때 자료에 접근하는 방법
	* 크롤링(스크래핑)과 같은 뜻이다.

2. c(client) /s(server) 서버 프로그램 작성하는 방법 (핵심방법)
	서버 - 클라이언트 (보통 채팅프로그램)

p1052

네트워크는 여러 대의 컴퓨터를 통신 회선으로 연결한 것으로 말한다. 만약 집에 방마다 컴퓨터가 있고, 이 컴퓨터들을 유무선 등의 통신 회선으로 연결했다면 홈네트워크가 형성된 것이다. 지역 네트워크(local = intranet)는 회사, 건물, 특정

영역에 존재하는 컴퓨터를 통신 회선으로 연결한 것을 말하고, 인터넷은 지역 네트워크를 통신 회선으로 연결한 것을 말한다.

 

18.6.1 서버와 클라이언트

컴퓨터가 인터넷에 연결되어 있다면 실제로 데이터를 주고받는 행위는 프로그램들이 한다.

서비스를 제공하는 프로그램을 일반적으로 서버(Server)라고 부르고, 서비스를 받는 프로그램을 클라이언트(Client)라고 부른다. 클라이언트는 서비스를 받기 위해 연결을 요청하고, 서버는 연결을 수락하여 서비스를 제공한다.

서버는 클라이언트 요청(request)하는 내용을 처리해주소, 응답(response)을 클라이언트로 보낸다.

 

클라이언트/서버 모델은 한 개의 서버와 다수의 클라이언트로 구성되는 것이 보통이나 두 개의 프로그램이 서버인 동시에 클라이언트 역할을 하는 P2P(peer to peer)모델도 있다. p2p 모델에서는 먼저 접속을 시도한 컴퓨터가 클라이언트가 된다.

 

18.6.2 IP 주소와 포트(Port)

컴퓨터의 고유한 주소를 IP(Internet Protocol)이라고 한다. IP주소는 네트워크 어댑터(랜카드)마다 할당되는데, 

한 개의 컴퓨터에 두 개의 네트워크 어댑터가 장착되어 있다면, 두 개의 ip 주소를 할당할 수 있다.

ip주소는 xxx.xxx.xxx.xxx.와 같은 형식인데 xxx는 부호없는 0~255사이의 정수이다.

연결할 상대방 컴퓨터의 ip주소를 모른다면 프로그램들은 통신할 수 없다.

또한 ip주소는 DNS(Domain Name System)를 이용해서 매칭할 수 있다.

예를 들면 네이버의 도메인 주소 www.naver.com은 222.122.195.5와 같다.

 

다음으로 포트에 대한 내용이다.

한 대의 컴퓨터에는 다양한 서버 프로그램들이 실행될 수 있다. 웹서버, 데이터베이스 서버, 파일공유서버 등등

이 경우 클라이언트는 어떤 서버와 통신해야 할지 결정해야 한다. IP는 컴퓨터의 네트워크 어댑터까지만 갈 수 있는 정보이기 때문에 컴퓨터 내에서 실행하는 서버를 선택하기 위해서는 추가적인 정보가 필요하다.

이 정보가 포트(Port)이다. 

 

서버는 시작할 때 고정적인 포트 번호를 가지고 실행하는데, 이것을 포트 바인딩(binding)이라고 한다.

클라이언트도 서버에서 보낸 정보를 받기 위해 포트 번호가 필요한데, 서버와 같이 고정적인 포트번호가 아니라

운영체제가 자동으로 부여하는 동적 포트 번호를 사용한다. 이 동적 포트 번호는 클라이언트가 서버로 연결 요청을 할 때 전송되어 서버가 클라이언트로 데이터를 보낼 때 사용된다.

 

18.6.3 InetAddress로 IP주소 얻기

자바에서 클라이언트와 서버의 연결은 java.net 패키지가 담당해서 ip주소를 알 수 있고,

실제 데이터 통신은 java.io 패키지에서 담당한다.

 

cmd창에서 특정 도메인의 ip주소를 얻을 수 있다. 방법은 아래와 같다.

이번에는 자바에서 네이버 도메인의 ip주소 얻어보자.

package NetworkEx;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class NetworkEx01 {

	public static void main(String[] args) {
		try {
			//네이버의 ip조회하기
			//ip가 바뀌어서 나오는 것은 해킹에 대비한 것이다.
			
			//ip주소 하나만 얻기
			System.out.println("---ip주소 하나만 얻기---");
			InetAddress inetAddress1 = InetAddress.getByName("www.naver.com");
			System.out.println( inetAddress1.getHostName() );
			System.out.println( inetAddress1.getHostAddress() );
			
			System.out.println("\n---ip주소 전체 다 얻기---");
			InetAddress[] inetAddresses = InetAddress.getAllByName("www.naver.com");
			for( InetAddress inetAddress : inetAddresses ) {
				System.out.println( inetAddress.getHostAddress() );
			}
			
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
---ip주소 하나만 얻기---
www.naver.com
125.209.222.141

---ip주소 전체 다 얻기---
125.209.222.141
223.130.195.95

 

* 특정 URL의 정보 가져오기

이번에는 url 저장용 클래스를 이용해서 url에 대한 부분적인 내용 가져와본다.

네이버 검색창에 covid-19를 검색한 뒤 url을 복사해온다.

package NetworkEx;

import java.net.MalformedURLException;
import java.net.URL;

public class NetworkEx02 {

	public static void main(String[] args) {
		//https://search.naver.com/search.naver?where=nexearch&sm=top_hty&fbm=0&ie=utf8&query=covid-19
		//url 저장용 클래스를 이용해서 url에 대한 부분적인 내용 가져오기
		
		try {
			URL url = new URL("https://search.naver.com/search.naver?where=nexearch&sm=top_hty&fbm=0&ie=utf8&query=covid-19");
			
			System.out.println(url.getProtocol());
			System.out.println(url.getHost());
			System.out.println(url.getPort());
			System.out.println(url.getPath());
			System.out.println(url.getQuery());
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
https
search.naver.com
-1
/search.naver
where=nexearch&sm=top_hty&fbm=0&ie=utf8&query=covid-19

이때 포트는 -1인데 현재 url에서 나타나있지 않아서 그렇다. 아래처럼 url에 포트를 지정해주면 출력이 된다.

URL url = new URL("https://search.naver.com:8080/search.naver?where=nexearch&sm=top_hty&fbm=0&ie=utf8&query=covid-19");

 

이번에는 특정 url의 html 문서를 자바의 openStream을 이용해서 불러와본다.

네이버의 html문서를 읽어와보자.

package NetworkEx;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

public class NetworkEx03 {

	public static void main(String[] args) {
		InputStream is = null;
		
		try {
			//특정 url의 html문서를 openStream을 이용해서 불러오기
			URL url = new URL( "https://m.naver.com" );
			is = url.openStream();
			int data = 0;
			while( (data = is.read()) != -1 ) {
				System.out.print( (char)data );
			}
			System.out.println();
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if ( is != null ) try { is.close(); } catch(IOException e) {}
		}
	}
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
"serviceMeta": {"metadata":{"svc.booking:1":{"title":"??¤??´?²??????½","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/75_resevation.png","badge":"","url":"https://m.booking.naver.com/booked/list","onlyNext":false},"svc.talkptncenter:1":{"title":"??¡??¡ ?????¸?????¼??°","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_202247362177.png","badge":"","url":"https://partner.talk.naver.com/","onlyNext":true},"svc.svdic:1":{"title":"??¤??¨??´??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/64_swedish.png","badge":"","url":"https://dict.naver.com/svkodict/#/main","onlyNext":false},"svc.modoo:1":{"title":"modoo!","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/138_modoo.png","badge":"","url":"http://www.modoo.at/home?&mobile=1","onlyNext":false},"svc.Influencer:1":{"title":"??¸?????¨??¸????²????","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/1118/mobile_18404606269.png","badge":"","url":"https://in.naver.com/","onlyNext":false},"svc.kin:1":{"title":"?§????iN","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/103_k-in.png","badge":"","url":"https://m.kin.naver.com/mobile/index.nhn","onlyNext":false},"svc.aldic:1":{"title":"????°?????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/69_albania.png","badge":"","url":"https://dict.naver.com/sqkodict/#/main","onlyNext":false},"svc.signtax:1":{"title":"????????¸???","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0701/mobile_172543494318.png","badge":"","url":"https://invoice.naver.com/main","onlyNext":false},"svc.department:1":{"title":"?°±????????????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/48_shop-depart.png","badge":"","url":"https://m.swindow.naver.com/department/home","onlyNext":false},"svc.gedic:1":{"title":"?¡°?§??????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/91_je.png","badge":"","url":"https://dict.naver.com/kakodict/#/main","onlyNext":false},"svc.swdic:1":{"title":"??¤???????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/63_swahili.png","badge":"","url":"https://dict.naver.com/swkodict/#/main","onlyNext":false},"svc.dedic:1":{"title":"?????¼??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/17_german.png","badge":"","url":"https://dict.naver.com/dekodict/#/main","onlyNext":false},"svc.cword:1":{"title":"?¤???­??´??¨??´???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/94_chiword.png","badge":"","url":"https://learn.dict.naver.com/m/cndic/main.nhn","onlyNext":false},"svc.partners:1":{"title":"?????¸?????¤?????´","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_203701997914.png","badge":"","url":"https://partners.naver.com/","onlyNext":true},"svc.khdic:1":{"title":"?º??³´????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/110_km.png","badge":"","url":"https://dict.naver.com/kmkodict/#/main","onlyNext":false},"svc.npay:1":{"title":"??¤??´?²??????´","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0302/mobile_143615452498.png","badge":"","url":"https://m.pay.naver.com/","onlyNext":false},"svc.keep:1":{"title":"Keep","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20190329/143_naverkeep.png","badge":"","url":"https://m.keep.naver.com/","onlyNext":false},"svc.mykodict:1":{"title":"??¸????§???´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_17083824268.png","badge":"","url":"https://dict.naver.com/mykodict/#/main","onlyNext":false},"svc.flights:1":{"title":"??­?³??¶?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/132_flight.png","badge":"","url":"https://m-tour.store.naver.com/flights","onlyNext":false},"svc.enter:1":{"title":"TV??°???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/71_entertain.png","badge":"","url":"http://m.entertain.naver.com/home","onlyNext":false},"svc.middic:1":{"title":"??¸?????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/87_india.png","badge":"","url":"https://dict.naver.com/idkodict/#/main","onlyNext":false},"svc.jrnaverapp:2":{"title":"???????²?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/97_jiniver_app.png","badge":"app","androidScheme":"jrnaverphone","androidPackage":"air.com.nhncorp.jrapp","androidQuery":"","onlyNext":false},"svc.whaleapp:2":{"title":"??¨??¼ ?¸???¼??°???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/82_wahle_app.png","badge":"app","androidScheme":"","androidPackage":"com.naver.whale","androidQuery":"","onlyNext":false},"svc.shopping:1":{"title":"??¤??´?²???¼???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/60_shopping.png","badge":"","url":"https://m.shopping.naver.com/home/m/index.nhn","onlyNext":false},"svc.weather:1":{"title":"?????¨","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/8_weather.png","badge":"","url":"https://weather.naver.com","onlyNext":false},"svc.kidswindow:1":{"title":"??¤?????????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/55_shop_kids.png","badge":"","url":"https://m.swindow.naver.com/kids/home","onlyNext":false},"svc.postapp:2":{"title":"?????¤??¸","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/124_post_app.png","badge":"app","androidScheme":"naverpost","androidPackage":"com.nhn.android.post","androidQuery":"goHome?version=1","onlyNext":false},"svc.lineapp:2":{"title":"??¼??¸","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/18_line_app.png","badge":"app","androidScheme":"line","androidPackage":"jp.naver.line.android","androidQuery":"run","onlyNext":false},"svc.moneybookapp:2":{"title":"?°??³??¶?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/3_household_app.png","badge":"app","androidScheme":"nhnmoneybook","androidPackage":"com.nhn.android.moneybook","androidQuery":"nodata","onlyNext":false},"svc.contact:1":{"title":"??¼????¡?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/92_contact.png","badge":"","url":"http://m.contact.naver.com","onlyNext":false},"svc.ladic:1":{"title":"??¼??´??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/19_latin.png","badge":"","url":"https://dict.naver.com/lakodict/#/main","onlyNext":false},"svc.comic:1":{"title":"??¹??°","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20181106/84_webtoon.png","badge":"","url":"http://m.comic.naver.com","onlyNext":false},"svc.clovaapp:2":{"title":"??¤??´?²? ??´?¡??°?","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0429/mobile_194012723250.png","badge":"app","androidScheme":"clova","androidPackage":"com.naver.nozzle","androidQuery":"landing?to=home","onlyNext":false},"svc.audioclip:1":{"title":"??¤?????¤??´??½","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/76_audioclip.png","badge":"","url":"https://audioclip.naver.com","onlyNext":false},"svc.hotels:1":{"title":"??¸???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/135_hotels.png","badge":"","url":"https://m-tour.store.naver.com/hotels","onlyNext":false},"svc.nilogin:1":{"title":"??¤??´?²? ?????´????¡? ?¡??·¸??¸","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_203855180759.png","badge":"","url":"https://nid.naver.com/user2/campaign/introNaverIdLoginMobile.nhn","onlyNext":true},"svc.vibeapp:2":{"title":"VIBE","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/30_vibe_app.png","badge":"app","androidScheme":"vibe","androidPackage":"com.naver.vibe","androidQuery":"action/go?to=main&tab=today","onlyNext":false},"svc.nlabs:1":{"title":"??¤??±??°??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/10_naverapplab.png.png","badge":"","url":"https://m.naver.com/lab/","onlyNext":false},"svc.hanja:1":{"title":"????????????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/131_chinescharacter.png","badge":"","url":"https://hanja.dict.naver.com/","onlyNext":false},"svc.memoapp:2":{"title":"????ª¨","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/23_memo_app.png","badge":"app","androidScheme":"comnhnnavermemo","androidPackage":"com.nhn.android.navermemo","androidQuery":"listMemo","onlyNext":false},"svc.dicapp:2":{"title":"??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/44_dict_app.png","badge":"app","androidScheme":"naverdic","androidPackage":"com.nhn.android.naverdic","androidQuery":"","onlyNext":false},"svc.mrudic:1":{"title":"???????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/20_russia.png","badge":"","url":"https://dict.naver.com/rukodict/#/main","onlyNext":false},"svc.vapp:2":{"title":"V LIVE","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/39_vlive_app.png","badge":"app","androidScheme":"globalv","androidPackage":"com.naver.vapp","androidQuery":"main","onlyNext":false},"svc.cafe:1":{"title":"?¹´???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/108_cafe.png","badge":"","url":"https://m.cafe.naver.com","onlyNext":false},"svc.spdic:1":{"title":"??¤?????¸??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/65_spain.png","badge":"","url":"https://dict.naver.com/eskodict/#/main","onlyNext":false},"svc.expert:1":{"title":"?????¤??¼??¸","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0320/mobile_160917931513.png","badge":"","url":"https://m.kin.naver.com/mobile/expert/home","onlyNext":false},"svc.seriesonapp:2":{"title":"???????????¨","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2018/0920/mobile_151632811181.png","badge":"app","androidScheme":"navertv","androidPackage":"com.nhn.android.navertv","androidQuery":"","onlyNext":false},"svc.sports:1":{"title":"??¤????¸?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/66_sports.png","badge":"","url":"http://m.sports.naver.com/","onlyNext":false},"svc.hudic:1":{"title":"????°??????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/134_hun.png","badge":"","url":"https://dict.naver.com/hukodict/#/main","onlyNext":false},"svc.catalan:1":{"title":"??°??´??°???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/15_datalab.png","badge":"","url":"https://m.datalab.naver.com/","onlyNext":false},"svc.papagoapp:2":{"title":"???????³?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/120_papago_app.png","badge":"app","androidScheme":"labspapago","androidPackage":"com.naver.labs.translator","androidQuery":"site.main","onlyNext":false},"svc.mailapp:2":{"title":"?????¼","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/25_mail_app.png","badge":"app","androidScheme":"navermail","androidPackage":"com.nhn.android.mail","androidQuery":"list?mailbox=inbox","onlyNext":false},"svc.bmk:1":{"title":"?¶??§????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/36_bookmark.png","badge":"","url":"http://m.bookmark.naver.com/mobile/index.nhn","onlyNext":false},"svc.post:1":{"title":"?????¤??¸","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/125_post.png","badge":"","url":"https://m.post.naver.com/","onlyNext":false},"svc.cafeapp:2":{"title":"?¹´???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/109_cafe_app.png","badge":"app","androidScheme":"navercafe","androidPackage":"com.nhn.android.navercafe","androidQuery":"section/home","onlyNext":false},"svc.bandapp:2":{"title":"?°´???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/32_band.png","badge":"app","androidScheme":"bandapp","androidPackage":"com.nhn.android.band","androidQuery":"band","onlyNext":false},"svc.ptdic:1":{"title":"?????´????°???´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/122_pt.png","badge":"","url":"https://dict.naver.com/ptkodict/#/main","onlyNext":false},"svc.rodic:1":{"title":"??¨?§?????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/21_rumania.png","badge":"","url":"https://dict.naver.com/rokodict/#/main","onlyNext":false},"svc.easybooking:1":{"title":"?????½ ?????¸?????¼??°","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_203557176760.png","badge":"","url":"https://easybooking.naver.com/","onlyNext":true},"svc.tvcastwebapp:2":{"title":"??¤??´?²?TV","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/11_ntv.png","badge":"app","androidScheme":"naverplayer","androidPackage":"com.nhn.android.naverplayer","androidQuery":"screen_main?minAppVersion=3400","onlyNext":false},"svc.beautywindow:1":{"title":"?·°??°??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/50_shop_beauty.png","badge":"","url":"https://m.swindow.naver.com/beauty/home","onlyNext":false},"svc.map:1":{"title":"?§????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/99_maps.png","badge":"","url":"https://m.map.naver.com","onlyNext":false},"svc.tetkodict:1":{"title":"?????¼??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_17101313375.png","badge":"","url":"https://dict.naver.com/tetkodict/#/main","onlyNext":false},"svc.vibe:1":{"title":"VIBE","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/29_vibe.png","badge":"","url":"https://vibe.naver.com/","onlyNext":false},"svc.membership:1":{"title":"??¤??´?²?????????¤ ??¤?²???­","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0528/mobile_142240911639.png","badge":"","url":"https://nid.naver.com/membership/my","onlyNext":false},"svc.nedic:1":{"title":"??¤?????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/12_nepal.png","badge":"","url":"https://dict.naver.com/nekodict/#/main","onlyNext":false},"svc.thdic:1":{"title":"?????­??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/117_thai.png","badge":"","url":"https://dict.naver.com/thkodict/#/main","onlyNext":false},"svc.invoice:1":{"title":"??¸??????","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0709/mobile_180821599731.png","badge":"","url":"https://nid.naver.com/user2/eSign/v1/home/land","onlyNext":false},"svc.stylewindow:1":{"title":"??¤?????¼??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/52_shop-style.png","badge":"","url":"https://m.swindow.naver.com/style/home","onlyNext":false},"svc.contactapp:2":{"title":"??¼????¡?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/93_contact_app.png","badge":"app","androidScheme":"navercontacts","androidPackage":"com.nhn.android.addressbookbackup","androidQuery":"view","onlyNext":false},"svc.calendar:1":{"title":"?º???°???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/111_calendar.png","badge":"","url":"https://m.calendar.naver.com/","onlyNext":false},"svc.hidic:1":{"title":"????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/136_hindi.png","badge":"","url":"https://dict.naver.com/hikodict/#/main","onlyNext":false},"svc.selective:1":{"title":"??¼?????¼??´?¸?","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0730/mobile_161304586843.png","badge":"","url":"https://shoppinglive.naver.com","onlyNext":false},"svc.pkgtour:1":{"title":"??¨??¤?§? ??????","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0704/mobile_182642462805.png","badge":"","url":"https://m-pkgtour.naver.com/","onlyNext":false},"svc.myplace:1":{"title":"MY????????´??¤","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/139_myplace.png","badge":"","url":"https://m.place.naver.com/my/","onlyNext":false},"svc.audioclipapp:2":{"title":"??¤?????¤??´??½","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/77_audioclip_app.png","badge":"app","androidScheme":"naveraudio","androidPackage":"com.naver.naveraudio","androidQuery":"move?to=home&version=6","onlyNext":false},"svc.mnmb:1":{"title":"??¤?§???¸ ????????´??¤","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/62_smartplace.png","badge":"","url":"https://m.smartplace.naver.com/","onlyNext":false},"svc.smartstore:1":{"title":"??¤?§???¸??¤?????´??¼??°","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_202829112823.png","badge":"","url":"https://sell.smartstore.naver.com/#/home/about","onlyNext":true},"svc.comicapp:2":{"title":"??¹??°","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20181106/85_webtoon_app.png","badge":"app","androidScheme":"webtoonkr","androidPackage":"com.nhn.android.webtoon","androidQuery":"default?version=1","onlyNext":false},"svc.seriesapp:2":{"title":"?????????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20190109/140_series.png","badge":"app","androidScheme":"naverbooks","androidPackage":"com.nhn.android.nbooks","androidQuery":"default","onlyNext":false},"svc.nldic:1":{"title":"??¤???????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/9_netherland.png","badge":"","url":"https://dict.naver.com/nlkodict/#/main","onlyNext":false},"svc.serieson:1":{"title":"???????????¨","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/1227/mobile_210822713210.png","badge":"","url":"https://m.serieson.naver.com/","onlyNext":false},"svc.bboom:1":{"title":"?¿?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/42_bboom.png","badge":"","url":"http://m.bboom.naver.com","onlyNext":false},"svc.mapapp:2":{"title":"?§????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/100_maps_app.png","badge":"app","androidScheme":"nmap","androidPackage":"com.nhn.android.nmap","androidQuery":"map","onlyNext":false},"svc.artwindow:1":{"title":"?????¸??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/54_shop_art.png","badge":"","url":"https://m.swindow.naver.com/art/home","onlyNext":false},"svc.mail:1":{"title":"?????¼","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/24_mail.png","badge":"","url":"https://m.mail.naver.com","onlyNext":false},"svc.mmndic:1":{"title":"?ª½?³¨??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/26_mongol.png","badge":"","url":"https://dict.naver.com/mnkodict/#/main","onlyNext":false},"svc.book:1":{"title":"?±?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/106_books.png","badge":"","url":"https://book.naver.com","onlyNext":false},"svc.blogapp:2":{"title":"?¸??¡??·¸","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/41_blog_app.png","badge":"app","androidScheme":"naverblog2","androidPackage":"com.nhn.android.blog","androidQuery":"","onlyNext":false},"svc.series:1":{"title":"?????????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20190109/140_series.png","badge":"","url":"https://m.series.naver.com","onlyNext":false},"svc.itdic:1":{"title":"??´???????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/86_italian.png","badge":"","url":"https://dict.naver.com/itkodict/#/main","onlyNext":false},"svc.whale:1":{"title":"??¨??¼ ?¸???¼??°???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/81_wahle.png","badge":"","url":"https://whale.naver.com","onlyNext":false},"svc.smartboardapp:2":{"title":"??¤?§???¸?³´???","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0822/mobile_114229621959.png","badge":"app","androidScheme":"","androidPackage":"com.navercorp.android.smartboard","androidQuery":"","onlyNext":false},"svc.fadic:1":{"title":"?????´????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/121_fa.png","badge":"","url":"https://dict.naver.com/fakodict/#/main","onlyNext":false},"svc.terms:1":{"title":"?§?????°±?³¼","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/102_encyclopedia.png","badge":"","url":"http://m.terms.naver.com/","onlyNext":false},"svc.talktalk:1":{"title":"??¡??¡","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/118_talk.png","badge":"","url":"https://talk.naver.com?frm=aside","onlyNext":false},"svc.opendict:1":{"title":"??¤?????????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/78_opendict.png","badge":"","url":"https://open.dict.naver.com/","onlyNext":false},"svc.trdic:1":{"title":"??°??¤??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/113_turkey.png","badge":"","url":"https://dict.naver.com/trkodict/#/main","onlyNext":false},"svc.dic:1":{"title":"??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/43_dict.png","badge":"","url":"https://dict.naver.com/","onlyNext":false},"svc.displayad:1":{"title":"?????¤????????´?´??³?","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_204344951107.png","badge":"","url":"https://displayad.naver.com/","onlyNext":true},"svc.dwindow:1":{"title":"????????´?????????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/46_shop-designer.png","badge":"","url":"https://m.swindow.naver.com/designer/site/11009001","onlyNext":false},"svc.ncloud:1":{"title":"??¤??´?²? ??´??¼??°??? ????????¼","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_20410082128.png","badge":"","url":"https://www.ncloud.com/","onlyNext":true},"svc.uzdic:1":{"title":"??°????²??????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/79_uzu.png","badge":"","url":"https://dict.naver.com/uzkodict/#/main","onlyNext":false},"svc.china:1":{"title":"?¤???­??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/95_chidict.png","badge":"","url":"https://zh.dict.naver.com/","onlyNext":false},"svc.papago:1":{"title":"???????³?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/119_papago.png","badge":"","url":"https://papago.naver.com/","onlyNext":false},"svc.globalshopping:1":{"title":"??´??¸?§????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/59_shop_global.png","badge":"","url":"https://m.swindow.naver.com/foreign/home","onlyNext":false},"svc.memo:1":{"title":"????ª¨","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/22_memo.png","badge":"","url":"http://m.memo.naver.com/mobile/memo.nhn","onlyNext":false},"svc.ardic:1":{"title":"????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/67_arab.png","badge":"","url":"https://dict.naver.com/arkodict/#/main","onlyNext":false},"svc.searchad:1":{"title":"?²?????´??³?","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_204310179762.png","badge":"","url":"https://m.searchad.naver.com/","onlyNext":true},"svc.news:1":{"title":"??´??¤","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/13_news.png","badge":"","url":"http://m.news.naver.com/","onlyNext":false},"svc.mr:1":{"title":"??¸??¤??°","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1014/mobile_1052268620.png","badge":"","url":"https://m.shopping.naver.com/mister/trends","onlyNext":false},"svc.stock:1":{"title":"????¶?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/98_fainace.png","badge":"","url":"http://m.stock.naver.com/","onlyNext":false},"svc.pldic:1":{"title":"??´????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/128_pol.png","badge":"","url":"https://dict.naver.com/plkodict/#/main","onlyNext":false},"svc.note:1":{"title":"?ª½?§?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/105_message.png","badge":"","url":"https://m.note.naver.com","onlyNext":false},"svc.csdic:1":{"title":"?²´?½???´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/107_cs.png","badge":"","url":"https://dict.naver.com/cskodict/#/main","onlyNext":false},"svc.tvcastweb:1":{"title":"??¤??´?²?TV","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/11_ntv.png","badge":"","url":"http://m.tv.naver.com","onlyNext":false},"svc.playwindow:1":{"title":"????????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/58_shop_game.png","badge":"","url":"https://m.swindow.naver.com/play/home","onlyNext":false},"svc.localtour:1":{"title":"????§??????´","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20190313/143_localtour.png","badge":"","url":"https://m-tour.store.naver.com/local","onlyNext":false},"svc.analytics:1":{"title":"??¤??´?²? ???????????±??¤","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_204021113180.png","badge":"","url":"https://analytics.naver.com/","onlyNext":true},"svc.eword:1":{"title":"?????¨??´???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/16_en-word.png","badge":"","url":"https://learn.dict.naver.com/m/endic/main.nhn","onlyNext":false},"svc.handmade:1":{"title":"????¹???????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/47_shop-living.png","badge":"","url":"https://m.swindow.naver.com/living/home","onlyNext":false},"svc.vndic:1":{"title":"?²???¸??¨??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/33_vi.png","badge":"","url":"https://dict.naver.com/vikodict/#/main","onlyNext":false},"svc.academic:1":{"title":"??????????³´","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/130_academic.png","badge":"","url":"http://m.academic.naver.com","onlyNext":false},"svc.calendarapp:2":{"title":"?º???°???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/112_calendar_app.png","badge":"app","androidScheme":"navercal","androidPackage":"com.nhn.android.calendar","androidQuery":"","onlyNext":false},"svc.works:1":{"title":"??¤??´?²??????¤","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1015/mobile_113833625522.png","badge":"","url":"https://naver.worksmobile.com/","onlyNext":true},"svc.ndriveapp:2":{"title":"MYBOX","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1110/mobile_151702668273.png","badge":"app","androidScheme":"comnhnndrive","androidPackage":"com.nhn.android.ndrive","androidQuery":"default?version=2","onlyNext":false},"svc.jpdic:1":{"title":"??¼?³¸??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/88_japdic.png","badge":"","url":"https://ja.dict.naver.com/","onlyNext":false},"svc.frdic:1":{"title":"????????¤??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/129_france.png","badge":"","url":"https://dict.naver.com/frkodict/#/main","onlyNext":false},"svc.mycar:1":{"title":"??¤??´?²? MY CAR","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1015/mobile_16463315820.png","badge":"","url":"https://new-m.pay.naver.com/mycar/","onlyNext":false},"svc.uadic:1":{"title":"??°?????¼??´?????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/80_uku.png","badge":"","url":"https://dict.naver.com/ukkodict/#/main","onlyNext":false},"svc.grafolio:1":{"title":"?·¸??¼??´?????¤","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/137_grafolio.png","badge":"","url":"https://m.grafolio.com","onlyNext":false},"svc.novel:1":{"title":"??¹?????¤","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1130/mobile_11224471873.png","badge":"","url":"http://m.novel.naver.com/","onlyNext":false},"svc.market:1":{"title":"??¤??´?²?????³´?¸°","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0827/mobile_150514759422.png","badge":"","url":"https://m.shopping.naver.com/market/home","onlyNext":false},"svc.outlet:1":{"title":"?????¸?????????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/53_shop-oulet.png","badge":"","url":"https://m.swindow.naver.com/outlet/home","onlyNext":false},"svc.endic:1":{"title":"?????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/72_endict.png","badge":"","url":"https://endic.naver.com/","onlyNext":false},"svc.localfood:1":{"title":"??¸?????????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/57_shop_food.png","badge":"","url":"https://m.swindow.naver.com/fresh/home","onlyNext":false},"svc.land:1":{"title":"?¶??????°","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/34_realestate.png","badge":"","url":"http://m.land.naver.com/","onlyNext":false},"svc.fikodict:1":{"title":"???????????´????????","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_171126993764.png","badge":"","url":"https://dict.naver.com/fikodict/finnish/#/main","onlyNext":false},"svc.elkodict:1":{"title":"?????????·¸?????¤??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_171252553249.png","badge":"","url":"https://dict.naver.com/elkodict/#/main","onlyNext":false},"svc.worksapp:2":{"title":"??¤??´?²??????¤","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1015/mobile_113909188964.png","badge":"app","androidScheme":"lineworks","androidPackage":"com.gworks.oneapp.works","androidQuery":"default?version=1","onlyNext":true},"svc.jrnaver:1":{"title":"???????²?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/96_jiniver.png","badge":"","url":"http://m.jr.naver.com/","onlyNext":false},"svc.petwindow:1":{"title":"?????????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/56_shop_pet.png","badge":"","url":"https://m.swindow.naver.com/pet/home","onlyNext":false},"svc.gift:1":{"title":"?????¼????¸°","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0925/mobile_194036243598.png","badge":"new","url":"https://m.shopping.naver.com/gift/home","onlyNext":false},"svc.korean:1":{"title":"??­??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/5_korean.png","badge":"","url":"https://ko.dict.naver.com/","onlyNext":false},"svc.ndrive:1":{"title":"MYBOX","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1110/mobile_151702668273.png","badge":"","url":"http://m.mybox.naver.com","onlyNext":false},"svc.wordquiz:1":{"title":"??¨??´??´???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/14_quiz.png","badge":"","url":"https://wquiz.dict.naver.com/main.dict","onlyNext":false},"svc.mnmbapp:2":{"title":"??¤?§???¸ ????????´??¤","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/1016/mobile_134305730426.png","badge":"app","androidScheme":"smartplace","androidPackage":"com.naver.smartplace","androidQuery":"open","onlyNext":false},"svc.toptop:1":{"title":"Toptop","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0715/mobile_145134834106.png","badge":"","url":"https://toptop.naver.com/m/","onlyNext":false},"svc.v:1":{"title":"V LIVE","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/38_vlive.png","badge":"","url":"http://vlive.tv","onlyNext":false},"svc.grckodict:1":{"title":"?³???????·¸?????¤??´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_165907600551.png","badge":"","url":"https://dict.naver.com/grckodict/#/main","onlyNext":false},"svc.smartboard:1":{"title":"??¤?§???¸?³´???","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0822/mobile_114441367570.png","badge":"","url":"http://keyboard.naver.com","onlyNext":false},"svc.kinapp:2":{"title":"?§????iN","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/104_k-in_app.png","badge":"app","androidScheme":"naverkin","androidPackage":"com.nhn.android.kin","androidQuery":"run","onlyNext":false},"svc.happybean:1":{"title":"??´??¼?¹?","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/133_happybean.png","badge":"","url":"http://m.happybean.naver.com","onlyNext":false},"svc.blog:1":{"title":"?¸??¡??·¸","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/40_blog.png","badge":"","url":"https://m.blog.naver.com","onlyNext":false},"svc.advisor:1":{"title":"???????????´??°??´????°???´???","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0722/mobile_141813812983.png","badge":"","url":"https://creator-advisor.naver.com","onlyNext":true},"svc.jword:1":{"title":"??¼?³¸??´??¨??´???","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/89_japword.png","badge":"","url":"https://learn.dict.naver.com/m/jpdic/main.nhn","onlyNext":false},"svc.hbokodict:1":{"title":"?³??????????¸??????´??????","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_170646673651.png","badge":"","url":"https://dict.naver.com/hbokodict/#/main??","onlyNext":false},"svc.landapp:2":{"title":"?¶??????°","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/35_reaestate_app.png","badge":"app","androidScheme":"comnhnland","androidPackage":"com.nhn.land.android","androidQuery":"","onlyNext":false},"svc.ngame:1":{"title":"??¤??´?²??²????","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1102/mobile_203732480936.png","badge":"","url":"https://m.game.naver.com","onlyNext":false},"svc.now:1":{"title":"NOW","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0906/mobile_110832555963.png","badge":"","url":"http://now.naver.com/","onlyNext":false}},"os":"ANDROID"},
"serviceExt": {
"svc.noti:1": {
"title": "?????¼",
"url": "https://m.me.naver.com/noti.nhn",
"iconUrl": "https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/68_noti.png"
}
}
}
</script>
<div id="MM_SHORTCUT_LAB_META" style="display:none;">
<div id="_MM_ASIDE_LAB_REVISION" data-lab-revision="26"></div>
</div>

</div>

</div>
<div class="flick-panel"></div>
</div>
--생략
</script>
</body>
</html>

현재 결과를 생략했지만 한글이 깨져나온다. 이것은 inputStream을 사용해서 그렇다.

한글을 깨지지않도록하려면 BufferedReader를 사용해야한다. 아래처럼 다시 코드를 작성한다.

만약 그래도 한글이 깨진다면 InputStreamReader에 "UTF-8"을 입력한다. 코드는 아래와 같다.

package NetworkEx;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

public class NetworkEx04 {

	public static void main(String[] args) {
		BufferedReader br = null;		//한 문장씩 읽기 위해
		
		try {
			//특정 url의 html문서를 openStream을 이용해서 불러오기
			URL url = new URL( "https://m.naver.com" );
			br = new BufferedReader(new InputStreamReader( url.openStream(), "UTF-8" ));
			String data = "";
			while( (data = br.readLine()) != null ) {
				System.out.println( data );
			}
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if ( br != null ) try { br.close(); } catch(IOException e) {}
		}
	}
}

 

이번에는 URLConnection 패키지를 이용해서 특정 url과의 연결정보를 출력해보자.

package NetworkEx;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class NetworkEx05 {

	public static void main(String[] args) {
		try {
			//특정 url 연결하기
			URL url = new URL("https://m.naver.com");
			URLConnection conn = url.openConnection();
			
			//url 연결에 대한 정보 출력하기
			System.out.println( conn );
			System.out.println( conn.getContent() );
			System.out.println( conn.getDate() );	//timestamp 형식으로 출력
			System.out.println( conn.getURL() );
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
sun.net.www.protocol.https.DelegateHttpsURLConnection:https://m.naver.com
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@157853da
1607059832000
https://m.naver.com

 

이번에는 URLConnection 을 이용해서 네이버의 html문서를 읽어보자.

package NetworkEx;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;


public class NetworkEx06 {

	public static void main(String[] args) {
		BufferedReader br = null;
		
		try {
			//특정 url 연결하기
			URL url = new URL("https://m.naver.com");
			URLConnection conn = url.openConnection();
			
			br = new BufferedReader(new InputStreamReader( conn.getInputStream(), "UTF-8"  ));
			String line = "";
			while( (line = br.readLine() ) != null ) {
				System.out.println( line );
			}
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if ( br != null ) try { br.close(); } catch(IOException e) {}
		}
	}
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
"serviceMeta": {"metadata":{"svc.booking:1":{"title":"네이버예약","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/75_resevation.png","badge":"","url":"https://m.booking.naver.com/booked/list","onlyNext":false},"svc.talkptncenter:1":{"title":"톡톡 파트너센터","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_202247362177.png","badge":"","url":"https://partner.talk.naver.com/","onlyNext":true},"svc.svdic:1":{"title":"스웨덴어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/64_swedish.png","badge":"","url":"https://dict.naver.com/svkodict/#/main","onlyNext":false},"svc.modoo:1":{"title":"modoo!","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/138_modoo.png","badge":"","url":"http://www.modoo.at/home?&mobile=1","onlyNext":false},"svc.Influencer:1":{"title":"인플루언서검색","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/1118/mobile_18404606269.png","badge":"","url":"https://in.naver.com/","onlyNext":false},"svc.kin:1":{"title":"지식iN","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/103_k-in.png","badge":"","url":"https://m.kin.naver.com/mobile/index.nhn","onlyNext":false},"svc.aldic:1":{"title":"알바니아어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/69_albania.png","badge":"","url":"https://dict.naver.com/sqkodict/#/main","onlyNext":false},"svc.signtax:1":{"title":"전자문서","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0701/mobile_172543494318.png","badge":"","url":"https://invoice.naver.com/main","onlyNext":false},"svc.department:1":{"title":"백화점윈도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/48_shop-depart.png","badge":"","url":"https://m.swindow.naver.com/department/home","onlyNext":false},"svc.gedic:1":{"title":"조지아어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/91_je.png","badge":"","url":"https://dict.naver.com/kakodict/#/main","onlyNext":false},"svc.swdic:1":{"title":"스와힐리어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/63_swahili.png","badge":"","url":"https://dict.naver.com/swkodict/#/main","onlyNext":false},"svc.dedic:1":{"title":"독일어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/17_german.png","badge":"","url":"https://dict.naver.com/dekodict/#/main","onlyNext":false},"svc.cword:1":{"title":"중국어단어장","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/94_chiword.png","badge":"","url":"https://learn.dict.naver.com/m/cndic/main.nhn","onlyNext":false},"svc.partners:1":{"title":"파트너스퀘어","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_203701997914.png","badge":"","url":"https://partners.naver.com/","onlyNext":true},"svc.khdic:1":{"title":"캄보디아어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/110_km.png","badge":"","url":"https://dict.naver.com/kmkodict/#/main","onlyNext":false},"svc.npay:1":{"title":"네이버페이","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0302/mobile_143615452498.png","badge":"","url":"https://m.pay.naver.com/","onlyNext":false},"svc.keep:1":{"title":"Keep","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20190329/143_naverkeep.png","badge":"","url":"https://m.keep.naver.com/","onlyNext":false},"svc.mykodict:1":{"title":"미얀마어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_17083824268.png","badge":"","url":"https://dict.naver.com/mykodict/#/main","onlyNext":false},"svc.flights:1":{"title":"항공권","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/132_flight.png","badge":"","url":"https://m-tour.store.naver.com/flights","onlyNext":false},"svc.enter:1":{"title":"TV연예","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/71_entertain.png","badge":"","url":"http://m.entertain.naver.com/home","onlyNext":false},"svc.middic:1":{"title":"인니어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/87_india.png","badge":"","url":"https://dict.naver.com/idkodict/#/main","onlyNext":false},"svc.jrnaverapp:2":{"title":"쥬니버","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/97_jiniver_app.png","badge":"app","androidScheme":"jrnaverphone","androidPackage":"air.com.nhncorp.jrapp","androidQuery":"","onlyNext":false},"svc.whaleapp:2":{"title":"웨일 브라우저","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/82_wahle_app.png","badge":"app","androidScheme":"","androidPackage":"com.naver.whale","androidQuery":"","onlyNext":false},"svc.shopping:1":{"title":"네이버쇼핑","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/60_shopping.png","badge":"","url":"https://m.shopping.naver.com/home/m/index.nhn","onlyNext":false},"svc.weather:1":{"title":"날씨","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/8_weather.png","badge":"","url":"https://weather.naver.com","onlyNext":false},"svc.kidswindow:1":{"title":"키즈윈도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/55_shop_kids.png","badge":"","url":"https://m.swindow.naver.com/kids/home","onlyNext":false},"svc.postapp:2":{"title":"포스트","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/124_post_app.png","badge":"app","androidScheme":"naverpost","androidPackage":"com.nhn.android.post","androidQuery":"goHome?version=1","onlyNext":false},"svc.lineapp:2":{"title":"라인","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/18_line_app.png","badge":"app","androidScheme":"line","androidPackage":"jp.naver.line.android","androidQuery":"run","onlyNext":false},"svc.moneybookapp:2":{"title":"가계부","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/3_household_app.png","badge":"app","androidScheme":"nhnmoneybook","androidPackage":"com.nhn.android.moneybook","androidQuery":"nodata","onlyNext":false},"svc.contact:1":{"title":"주소록","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/92_contact.png","badge":"","url":"http://m.contact.naver.com","onlyNext":false},"svc.ladic:1":{"title":"라틴어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/19_latin.png","badge":"","url":"https://dict.naver.com/lakodict/#/main","onlyNext":false},"svc.comic:1":{"title":"웹툰","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20181106/84_webtoon.png","badge":"","url":"http://m.comic.naver.com","onlyNext":false},"svc.clovaapp:2":{"title":"네이버 클로바","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0429/mobile_194012723250.png","badge":"app","androidScheme":"clova","androidPackage":"com.naver.nozzle","androidQuery":"landing?to=home","onlyNext":false},"svc.audioclip:1":{"title":"오디오클립","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/76_audioclip.png","badge":"","url":"https://audioclip.naver.com","onlyNext":false},"svc.hotels:1":{"title":"호텔","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/135_hotels.png","badge":"","url":"https://m-tour.store.naver.com/hotels","onlyNext":false},"svc.nilogin:1":{"title":"네이버 아이디로 로그인","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_203855180759.png","badge":"","url":"https://nid.naver.com/user2/campaign/introNaverIdLoginMobile.nhn","onlyNext":true},"svc.vibeapp:2":{"title":"VIBE","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/30_vibe_app.png","badge":"app","androidScheme":"vibe","androidPackage":"com.naver.vibe","androidQuery":"action/go?to=main&tab=today","onlyNext":false},"svc.nlabs:1":{"title":"네앱연구소","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/10_naverapplab.png.png","badge":"","url":"https://m.naver.com/lab/","onlyNext":false},"svc.hanja:1":{"title":"한자사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/131_chinescharacter.png","badge":"","url":"https://hanja.dict.naver.com/","onlyNext":false},"svc.memoapp:2":{"title":"메모","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/23_memo_app.png","badge":"app","androidScheme":"comnhnnavermemo","androidPackage":"com.nhn.android.navermemo","androidQuery":"listMemo","onlyNext":false},"svc.dicapp:2":{"title":"사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/44_dict_app.png","badge":"app","androidScheme":"naverdic","androidPackage":"com.nhn.android.naverdic","androidQuery":"","onlyNext":false},"svc.mrudic:1":{"title":"러시아어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/20_russia.png","badge":"","url":"https://dict.naver.com/rukodict/#/main","onlyNext":false},"svc.vapp:2":{"title":"V LIVE","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/39_vlive_app.png","badge":"app","androidScheme":"globalv","androidPackage":"com.naver.vapp","androidQuery":"main","onlyNext":false},"svc.cafe:1":{"title":"카페","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/108_cafe.png","badge":"","url":"https://m.cafe.naver.com","onlyNext":false},"svc.spdic:1":{"title":"스페인어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/65_spain.png","badge":"","url":"https://dict.naver.com/eskodict/#/main","onlyNext":false},"svc.expert:1":{"title":"엑스퍼트","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0320/mobile_160917931513.png","badge":"","url":"https://m.kin.naver.com/mobile/expert/home","onlyNext":false},"svc.seriesonapp:2":{"title":"시리즈온","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2018/0920/mobile_151632811181.png","badge":"app","androidScheme":"navertv","androidPackage":"com.nhn.android.navertv","androidQuery":"","onlyNext":false},"svc.sports:1":{"title":"스포츠","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/66_sports.png","badge":"","url":"http://m.sports.naver.com/","onlyNext":false},"svc.hudic:1":{"title":"헝가리어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/134_hun.png","badge":"","url":"https://dict.naver.com/hukodict/#/main","onlyNext":false},"svc.catalan:1":{"title":"데이터랩","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/15_datalab.png","badge":"","url":"https://m.datalab.naver.com/","onlyNext":false},"svc.papagoapp:2":{"title":"파파고","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/120_papago_app.png","badge":"app","androidScheme":"labspapago","androidPackage":"com.naver.labs.translator","androidQuery":"site.main","onlyNext":false},"svc.mailapp:2":{"title":"메일","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/25_mail_app.png","badge":"app","androidScheme":"navermail","androidPackage":"com.nhn.android.mail","androidQuery":"list?mailbox=inbox","onlyNext":false},"svc.bmk:1":{"title":"북마크","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/36_bookmark.png","badge":"","url":"http://m.bookmark.naver.com/mobile/index.nhn","onlyNext":false},"svc.post:1":{"title":"포스트","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/125_post.png","badge":"","url":"https://m.post.naver.com/","onlyNext":false},"svc.cafeapp:2":{"title":"카페","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/109_cafe_app.png","badge":"app","androidScheme":"navercafe","androidPackage":"com.nhn.android.navercafe","androidQuery":"section/home","onlyNext":false},"svc.bandapp:2":{"title":"밴드","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/32_band.png","badge":"app","androidScheme":"bandapp","androidPackage":"com.nhn.android.band","androidQuery":"band","onlyNext":false},"svc.ptdic:1":{"title":"포르투갈어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/122_pt.png","badge":"","url":"https://dict.naver.com/ptkodict/#/main","onlyNext":false},"svc.rodic:1":{"title":"루마니아어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/21_rumania.png","badge":"","url":"https://dict.naver.com/rokodict/#/main","onlyNext":false},"svc.easybooking:1":{"title":"예약 파트너센터","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_203557176760.png","badge":"","url":"https://easybooking.naver.com/","onlyNext":true},"svc.tvcastwebapp:2":{"title":"네이버TV","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/11_ntv.png","badge":"app","androidScheme":"naverplayer","androidPackage":"com.nhn.android.naverplayer","androidQuery":"screen_main?minAppVersion=3400","onlyNext":false},"svc.beautywindow:1":{"title":"뷰티윈도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/50_shop_beauty.png","badge":"","url":"https://m.swindow.naver.com/beauty/home","onlyNext":false},"svc.map:1":{"title":"지도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/99_maps.png","badge":"","url":"https://m.map.naver.com","onlyNext":false},"svc.tetkodict:1":{"title":"테툼어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_17101313375.png","badge":"","url":"https://dict.naver.com/tetkodict/#/main","onlyNext":false},"svc.vibe:1":{"title":"VIBE","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/29_vibe.png","badge":"","url":"https://vibe.naver.com/","onlyNext":false},"svc.membership:1":{"title":"네이버플러스 멤버십","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0528/mobile_142240911639.png","badge":"","url":"https://nid.naver.com/membership/my","onlyNext":false},"svc.nedic:1":{"title":"네팔어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/12_nepal.png","badge":"","url":"https://dict.naver.com/nekodict/#/main","onlyNext":false},"svc.thdic:1":{"title":"태국어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/117_thai.png","badge":"","url":"https://dict.naver.com/thkodict/#/main","onlyNext":false},"svc.invoice:1":{"title":"인증서","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0709/mobile_180821599731.png","badge":"","url":"https://nid.naver.com/user2/eSign/v1/home/land","onlyNext":false},"svc.stylewindow:1":{"title":"스타일윈도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/52_shop-style.png","badge":"","url":"https://m.swindow.naver.com/style/home","onlyNext":false},"svc.contactapp:2":{"title":"주소록","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/93_contact_app.png","badge":"app","androidScheme":"navercontacts","androidPackage":"com.nhn.android.addressbookbackup","androidQuery":"view","onlyNext":false},"svc.calendar:1":{"title":"캘린더","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/111_calendar.png","badge":"","url":"https://m.calendar.naver.com/","onlyNext":false},"svc.hidic:1":{"title":"힌디어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/136_hindi.png","badge":"","url":"https://dict.naver.com/hikodict/#/main","onlyNext":false},"svc.selective:1":{"title":"쇼핑라이브","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0730/mobile_161304586843.png","badge":"","url":"https://shoppinglive.naver.com","onlyNext":false},"svc.pkgtour:1":{"title":"패키지 여행","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0704/mobile_182642462805.png","badge":"","url":"https://m-pkgtour.naver.com/","onlyNext":false},"svc.myplace:1":{"title":"MY플레이스","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/139_myplace.png","badge":"","url":"https://m.place.naver.com/my/","onlyNext":false},"svc.audioclipapp:2":{"title":"오디오클립","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/77_audioclip_app.png","badge":"app","androidScheme":"naveraudio","androidPackage":"com.naver.naveraudio","androidQuery":"move?to=home&version=6","onlyNext":false},"svc.mnmb:1":{"title":"스마트 플레이스","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/62_smartplace.png","badge":"","url":"https://m.smartplace.naver.com/","onlyNext":false},"svc.smartstore:1":{"title":"스마트스토어센터","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_202829112823.png","badge":"","url":"https://sell.smartstore.naver.com/#/home/about","onlyNext":true},"svc.comicapp:2":{"title":"웹툰","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20181106/85_webtoon_app.png","badge":"app","androidScheme":"webtoonkr","androidPackage":"com.nhn.android.webtoon","androidQuery":"default?version=1","onlyNext":false},"svc.seriesapp:2":{"title":"시리즈","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20190109/140_series.png","badge":"app","androidScheme":"naverbooks","androidPackage":"com.nhn.android.nbooks","androidQuery":"default","onlyNext":false},"svc.nldic:1":{"title":"네덜란드어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/9_netherland.png","badge":"","url":"https://dict.naver.com/nlkodict/#/main","onlyNext":false},"svc.serieson:1":{"title":"시리즈온","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/1227/mobile_210822713210.png","badge":"","url":"https://m.serieson.naver.com/","onlyNext":false},"svc.bboom:1":{"title":"뿜","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/42_bboom.png","badge":"","url":"http://m.bboom.naver.com","onlyNext":false},"svc.mapapp:2":{"title":"지도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/100_maps_app.png","badge":"app","androidScheme":"nmap","androidPackage":"com.nhn.android.nmap","androidQuery":"map","onlyNext":false},"svc.artwindow:1":{"title":"아트윈도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/54_shop_art.png","badge":"","url":"https://m.swindow.naver.com/art/home","onlyNext":false},"svc.mail:1":{"title":"메일","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/24_mail.png","badge":"","url":"https://m.mail.naver.com","onlyNext":false},"svc.mmndic:1":{"title":"몽골어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/26_mongol.png","badge":"","url":"https://dict.naver.com/mnkodict/#/main","onlyNext":false},"svc.book:1":{"title":"책","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/106_books.png","badge":"","url":"https://book.naver.com","onlyNext":false},"svc.blogapp:2":{"title":"블로그","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/41_blog_app.png","badge":"app","androidScheme":"naverblog2","androidPackage":"com.nhn.android.blog","androidQuery":"","onlyNext":false},"svc.series:1":{"title":"시리즈","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20190109/140_series.png","badge":"","url":"https://m.series.naver.com","onlyNext":false},"svc.itdic:1":{"title":"이탈리아어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/86_italian.png","badge":"","url":"https://dict.naver.com/itkodict/#/main","onlyNext":false},"svc.whale:1":{"title":"웨일 브라우저","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/81_wahle.png","badge":"","url":"https://whale.naver.com","onlyNext":false},"svc.smartboardapp:2":{"title":"스마트보드","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0822/mobile_114229621959.png","badge":"app","androidScheme":"","androidPackage":"com.navercorp.android.smartboard","androidQuery":"","onlyNext":false},"svc.fadic:1":{"title":"페르시아어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/121_fa.png","badge":"","url":"https://dict.naver.com/fakodict/#/main","onlyNext":false},"svc.terms:1":{"title":"지식백과","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/102_encyclopedia.png","badge":"","url":"http://m.terms.naver.com/","onlyNext":false},"svc.talktalk:1":{"title":"톡톡","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/118_talk.png","badge":"","url":"https://talk.naver.com?frm=aside","onlyNext":false},"svc.opendict:1":{"title":"오픈사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/78_opendict.png","badge":"","url":"https://open.dict.naver.com/","onlyNext":false},"svc.trdic:1":{"title":"터키어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/113_turkey.png","badge":"","url":"https://dict.naver.com/trkodict/#/main","onlyNext":false},"svc.dic:1":{"title":"사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/43_dict.png","badge":"","url":"https://dict.naver.com/","onlyNext":false},"svc.displayad:1":{"title":"디스플레이광고","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_204344951107.png","badge":"","url":"https://displayad.naver.com/","onlyNext":true},"svc.dwindow:1":{"title":"디자이너윈도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/46_shop-designer.png","badge":"","url":"https://m.swindow.naver.com/designer/site/11009001","onlyNext":false},"svc.ncloud:1":{"title":"네이버 클라우드 플랫폼","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_20410082128.png","badge":"","url":"https://www.ncloud.com/","onlyNext":true},"svc.uzdic:1":{"title":"우즈베크어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/79_uzu.png","badge":"","url":"https://dict.naver.com/uzkodict/#/main","onlyNext":false},"svc.china:1":{"title":"중국어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/95_chidict.png","badge":"","url":"https://zh.dict.naver.com/","onlyNext":false},"svc.papago:1":{"title":"파파고","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/119_papago.png","badge":"","url":"https://papago.naver.com/","onlyNext":false},"svc.globalshopping:1":{"title":"해외직구","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/59_shop_global.png","badge":"","url":"https://m.swindow.naver.com/foreign/home","onlyNext":false},"svc.memo:1":{"title":"메모","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/22_memo.png","badge":"","url":"http://m.memo.naver.com/mobile/memo.nhn","onlyNext":false},"svc.ardic:1":{"title":"아랍어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/67_arab.png","badge":"","url":"https://dict.naver.com/arkodict/#/main","onlyNext":false},"svc.searchad:1":{"title":"검색광고","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_204310179762.png","badge":"","url":"https://m.searchad.naver.com/","onlyNext":true},"svc.news:1":{"title":"뉴스","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/13_news.png","badge":"","url":"http://m.news.naver.com/","onlyNext":false},"svc.mr:1":{"title":"미스터","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1014/mobile_1052268620.png","badge":"","url":"https://m.shopping.naver.com/mister/trends","onlyNext":false},"svc.stock:1":{"title":"증권","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/98_fainace.png","badge":"","url":"http://m.stock.naver.com/","onlyNext":false},"svc.pldic:1":{"title":"폴란드어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/128_pol.png","badge":"","url":"https://dict.naver.com/plkodict/#/main","onlyNext":false},"svc.note:1":{"title":"쪽지","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/105_message.png","badge":"","url":"https://m.note.naver.com","onlyNext":false},"svc.csdic:1":{"title":"체코어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/107_cs.png","badge":"","url":"https://dict.naver.com/cskodict/#/main","onlyNext":false},"svc.tvcastweb:1":{"title":"네이버TV","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/11_ntv.png","badge":"","url":"http://m.tv.naver.com","onlyNext":false},"svc.playwindow:1":{"title":"플레이윈도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/58_shop_game.png","badge":"","url":"https://m.swindow.naver.com/play/home","onlyNext":false},"svc.localtour:1":{"title":"현지투어","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20190313/143_localtour.png","badge":"","url":"https://m-tour.store.naver.com/local","onlyNext":false},"svc.analytics:1":{"title":"네이버 애널리틱스","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0319/mobile_204021113180.png","badge":"","url":"https://analytics.naver.com/","onlyNext":true},"svc.eword:1":{"title":"영단어장","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/16_en-word.png","badge":"","url":"https://learn.dict.naver.com/m/endic/main.nhn","onlyNext":false},"svc.handmade:1":{"title":"리빙윈도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/47_shop-living.png","badge":"","url":"https://m.swindow.naver.com/living/home","onlyNext":false},"svc.vndic:1":{"title":"베트남어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/33_vi.png","badge":"","url":"https://dict.naver.com/vikodict/#/main","onlyNext":false},"svc.academic:1":{"title":"학술정보","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/130_academic.png","badge":"","url":"http://m.academic.naver.com","onlyNext":false},"svc.calendarapp:2":{"title":"캘린더","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/112_calendar_app.png","badge":"app","androidScheme":"navercal","androidPackage":"com.nhn.android.calendar","androidQuery":"","onlyNext":false},"svc.works:1":{"title":"네이버웍스","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1015/mobile_113833625522.png","badge":"","url":"https://naver.worksmobile.com/","onlyNext":true},"svc.ndriveapp:2":{"title":"MYBOX","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1110/mobile_151702668273.png","badge":"app","androidScheme":"comnhnndrive","androidPackage":"com.nhn.android.ndrive","androidQuery":"default?version=2","onlyNext":false},"svc.jpdic:1":{"title":"일본어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/88_japdic.png","badge":"","url":"https://ja.dict.naver.com/","onlyNext":false},"svc.frdic:1":{"title":"프랑스어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/129_france.png","badge":"","url":"https://dict.naver.com/frkodict/#/main","onlyNext":false},"svc.mycar:1":{"title":"네이버 MY CAR","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1015/mobile_16463315820.png","badge":"","url":"https://new-m.pay.naver.com/mycar/","onlyNext":false},"svc.uadic:1":{"title":"우크라이나어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/80_uku.png","badge":"","url":"https://dict.naver.com/ukkodict/#/main","onlyNext":false},"svc.grafolio:1":{"title":"그라폴리오","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/137_grafolio.png","badge":"","url":"https://m.grafolio.com","onlyNext":false},"svc.novel:1":{"title":"웹소설","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1130/mobile_11224471873.png","badge":"","url":"http://m.novel.naver.com/","onlyNext":false},"svc.market:1":{"title":"네이버장보기","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0827/mobile_150514759422.png","badge":"","url":"https://m.shopping.naver.com/market/home","onlyNext":false},"svc.outlet:1":{"title":"아울렛윈도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/53_shop-oulet.png","badge":"","url":"https://m.swindow.naver.com/outlet/home","onlyNext":false},"svc.endic:1":{"title":"영어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/72_endict.png","badge":"","url":"https://endic.naver.com/","onlyNext":false},"svc.localfood:1":{"title":"푸드윈도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/57_shop_food.png","badge":"","url":"https://m.swindow.naver.com/fresh/home","onlyNext":false},"svc.land:1":{"title":"부동산","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/34_realestate.png","badge":"","url":"http://m.land.naver.com/","onlyNext":false},"svc.fikodict:1":{"title":"핀란드어사전?","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_171126993764.png","badge":"","url":"https://dict.naver.com/fikodict/finnish/#/main","onlyNext":false},"svc.elkodict:1":{"title":"현대?그리스어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_171252553249.png","badge":"","url":"https://dict.naver.com/elkodict/#/main","onlyNext":false},"svc.worksapp:2":{"title":"네이버웍스","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1015/mobile_113909188964.png","badge":"app","androidScheme":"lineworks","androidPackage":"com.gworks.oneapp.works","androidQuery":"default?version=1","onlyNext":true},"svc.jrnaver:1":{"title":"쥬니버","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/96_jiniver.png","badge":"","url":"http://m.jr.naver.com/","onlyNext":false},"svc.petwindow:1":{"title":"펫윈도","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/56_shop_pet.png","badge":"","url":"https://m.swindow.naver.com/pet/home","onlyNext":false},"svc.gift:1":{"title":"선물하기","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0925/mobile_194036243598.png","badge":"new","url":"https://m.shopping.naver.com/gift/home","onlyNext":false},"svc.korean:1":{"title":"국어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/5_korean.png","badge":"","url":"https://ko.dict.naver.com/","onlyNext":false},"svc.ndrive:1":{"title":"MYBOX","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1110/mobile_151702668273.png","badge":"","url":"http://m.mybox.naver.com","onlyNext":false},"svc.wordquiz:1":{"title":"단어퀴즈","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/14_quiz.png","badge":"","url":"https://wquiz.dict.naver.com/main.dict","onlyNext":false},"svc.mnmbapp:2":{"title":"스마트 플레이스","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/1016/mobile_134305730426.png","badge":"app","androidScheme":"smartplace","androidPackage":"com.naver.smartplace","androidQuery":"open","onlyNext":false},"svc.toptop:1":{"title":"Toptop","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0715/mobile_145134834106.png","badge":"","url":"https://toptop.naver.com/m/","onlyNext":false},"svc.v:1":{"title":"V LIVE","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/38_vlive.png","badge":"","url":"http://vlive.tv","onlyNext":false},"svc.grckodict:1":{"title":"고대?그리스어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_165907600551.png","badge":"","url":"https://dict.naver.com/grckodict/#/main","onlyNext":false},"svc.smartboard:1":{"title":"스마트보드","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0822/mobile_114441367570.png","badge":"","url":"http://keyboard.naver.com","onlyNext":false},"svc.kinapp:2":{"title":"지식iN","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/104_k-in_app.png","badge":"app","androidScheme":"naverkin","androidPackage":"com.nhn.android.kin","androidQuery":"run","onlyNext":false},"svc.happybean:1":{"title":"해피빈","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/133_happybean.png","badge":"","url":"http://m.happybean.naver.com","onlyNext":false},"svc.blog:1":{"title":"블로그","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/40_blog.png","badge":"","url":"https://m.blog.naver.com","onlyNext":false},"svc.advisor:1":{"title":"크리에이터어드바이저","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/0722/mobile_141813812983.png","badge":"","url":"https://creator-advisor.naver.com","onlyNext":true},"svc.jword:1":{"title":"일본어단어장","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/89_japword.png","badge":"","url":"https://learn.dict.naver.com/m/jpdic/main.nhn","onlyNext":false},"svc.hbokodict:1":{"title":"고대?히브리어사전","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0523/mobile_170646673651.png","badge":"","url":"https://dict.naver.com/hbokodict/#/main?","onlyNext":false},"svc.landapp:2":{"title":"부동산","iconUrl":"https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/35_reaestate_app.png","badge":"app","androidScheme":"comnhnland","androidPackage":"com.nhn.land.android","androidQuery":"","onlyNext":false},"svc.ngame:1":{"title":"네이버게임","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2020/1102/mobile_203732480936.png","badge":"","url":"https://m.game.naver.com","onlyNext":false},"svc.now:1":{"title":"NOW","iconUrl":"https://s.pstatic.net/static/www/mobile/edit/2019/0906/mobile_110832555963.png","badge":"","url":"http://now.naver.com/","onlyNext":false}},"os":"ANDROID"},
"serviceExt": {
"svc.noti:1": {
"title": "알림",
"url": "https://m.me.naver.com/noti.nhn",
"iconUrl": "https://s.pstatic.net/static/www/mobile/up/service/allservice/20180914/68_noti.png"
}
}
}
</script>
<div id="MM_SHORTCUT_LAB_META" style="display:none;">
<div id="_MM_ASIDE_LAB_REVISION" data-lab-revision="26"></div>
</div>

</div>

</div>
<div class="flick-panel"></div>
</div>
</div>
<button id="MM_GREENDOT" type="button" class="sch_recognition greendot_out" data-clk="greend"><span class="ico_sch_recognition">인식검색</span></button>
<div id="MM_HOME_RECEIVED" class="float_banner_gift"></div>
<div id="MM_NEWS_FLOATING_BUTTON" class="grid_cui_prepend id_cui_channel_journal" style="display:none;">
<div class="cui_channel_journal ccj_set_fixed">
<button type="button" class="ccj_btn_set _MM_NEWS_CHANNEL_CATEGORY_BANNER_SAVE" data-from="main_category" data-clk="editnlthree">언론사 구독</button>
</div>
</div>
<div id="MM_DUAL_SETTING" class="float_realtime" style="display:none;">
<a href="/aside/" class="fr_banner">
<strong class="fr_title"><em class="fr_st fr_ham">삼선메뉴</em>에서 원하는 버전을 선택할 수 있어요</strong>
</a>
</div>

<div id="MM_SWIPE_COACH" class="float_coachmark fc_fade_out">
<a href="#" class="fc_banner" data-clk="swipe">
<strong class="fc_title" style="overflow:hidden;">
<span class="arrow_box_l"><span class="ico_arrow1"></span><span class="ico_arrow2"></span><span class="ico_arrow3"></span></span>
<ul class="fc_list MM_list">
<li class="fc_item"><em class="fc_t">쇼핑</em>은 왼쪽에서</li>
<li class="fc_item"><em class="fc_t">뉴스</em>는 오른쪽에서</li>
</ul>
<span class="arrow_box_r"><span class="ico_arrow3"></span><span class="ico_arrow2"></span><span class="ico_arrow1"></span></span>
</strong>
</a>
</div>


--생략

 

이번에는 웹페이지의 이미지를 크롤링해보자.

웹사이트에서 아무 이미지 주소를 복사한다.

다음에서 '이미지' 검색하고 이미지 탭에서 아무 사진주소를 복사했다.

package NetworkEx;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class NetworkEx07 {

	public static void main(String[] args) {
		//가져올 이미지 url : https://search1.kakaocdn.net/argon/0x200_85_hr/DYmark5V3tI
		
		//이미지는 문자가 아니므로 input/output 스트림을 사용한다.
                //문자를 읽어올 때는 그냥 BufferedReader를 사용하면된다.
		BufferedInputStream bis = null;		
		BufferedOutputStream bos = null;
		
		try {
			//이미지 가져올 url과 자바 연결하기
			URLConnection conn = 
				new URL("https://search1.kakaocdn.net/argon/0x200_85_hr/DYmark5V3tI").openConnection();
			
			//bis 버퍼안에 이미지url의 정보를 집어넣고 bos버퍼를 통해서 image.jpg 파일을 만든다.
			bis = new BufferedInputStream( conn.getInputStream() );
			bos = new BufferedOutputStream( new FileOutputStream("./image.jpg") );
			
			//bis 버퍼안에있는 내용을 모두 읽어서 bos버퍼 안에 쓴다.
			int data = 0;
			while( (data = bis.read()) != -1 ) {
				bos.write( data );
			}
			System.out.println( "전송 완료" );
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if ( bis != null ) try { bis.close(); } catch(IOException e) {}
			if ( bos != null ) try { bos.close(); } catch(IOException e) {}
		}
	}
}

웹페이지에 있던 이미지를 자바에서 가져온 뒤 프로젝트 안에 생성된 것을 확인할 수 있다.

 

이번에는 다음 사이트에 있는 뉴스에서 아래 뉴스 제목들을 모두 불러와보자.

package NetworkEx;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;


public class NetworkEx08 {

	public static void main(String[] args) {
		//https://www.daum.net/
		BufferedReader br = null;
		
		
		try {
			//url과 자바 연결하기
			URLConnection conn = 
					new URL("https://www.daum.net/").openConnection();
			
			//버퍼 안에 해당 url 정보 집어넣기
			br = new BufferedReader(new InputStreamReader( conn.getInputStream(), "UTF-8" ));
			
			//문자열 크롤링하기
			String line = "";
			while( (line = br.readLine()) != null ) {
				
				//ul 태그 다음줄부터 다시 읽게한다.
				if( line.startsWith( "<ul class=\"list_txt\">") ) {
					while(true) {
						String htmlLine = br.readLine();
						
						//</ul> 태그 만날 때까지 반복, 만나면 while문 빠져나간다
						if( !htmlLine.equals("</ul>")) {
							
							//<a> 태그로 시작하는 라인에서 뉴스제목 전부터 뉴스제목 끝까지만 문자열 자른다.
							if (htmlLine.startsWith("<a")) {
								String news = htmlLine.substring(
										htmlLine.indexOf(">")+1, htmlLine.lastIndexOf("<") );
								//쓸데없는 문자열 공백으로 치환한다.
								 news = news.replaceAll("&middot;", "").replaceAll("&quot;", "")
										 .replaceAll("&#39;", "").replaceAll("[Q&amp;A]", "");
								 
								 System.out.println( news );
							}
						} else { break; }
					}
				}
			}
			
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if ( br != null ) try { br.close(); } catch(IOException e) {}
		}
	}
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
윤석열, 끝장 보겠다..文대통령 절차의 공정성에 위헌소송
서정협 서울 확진자, 예상속도 벗어났다..기하급수적[]
코로나19로 어려움 겪은 20만 가구에 최대 100만원 긴급생계비
금융노조 무분별한 은행 점포 폐쇄 반대..금감원 적극 나서라
홍콩 반중인사 지미 라이 구속에 회사 주가 한때 107% 폭등
與 개각 환영..변창흠 국토장관 후보자, 이론실무 겸비
거짓말로 7차감염 초래..인천 학원강사 항소심도 징역 6월
테러 협박 신고하러 온 외국인에 경찰 번역해 오라
국립산림과학원 한남시험림 화재..연구용 나무는 피해 없어
겨울이 왔네 강원 스키장 시즌 돌입..코로나19 방역 초긴장
현대차 상생안 공개되자..중고차 업계 사실상 양보 않겠다는 뜻
올해 대입설명회도 비대면 대세..대교협 정시박람회 취소 가능성
中가짜 사진에 천안문 맞불 호주..中전략에 낚였다
코로나 백신 상용화 눈앞.. 진단키트株의 운명은
정의연n번방 등 숱한 논란 직면..1년3개월만에 떠나는 이정옥

 

18.7  TCP 네트워킹

p1056

네트워킹
	TCP	- 전화(누가 걸면 누가 받고 하는 순수과정)
	UDP	- 방송(계속 방송하는 데 내가 필요한 부분만 듣고 요청)

TCP가 주로 많이 사용

ServerSocket을 만들 때 가장 중요한 것은 port이다.
Socket을 만들 때는 ip와 port가 필요하고 내용을 요청할 때 protocol이 필요하다.

따라서 두 개를 실행시켜야하는데
ServerSocket은 cmd에서 실행하고
Socket은 이클립스에서 실행한다.

 

실제로 ServerSocket과 Socket을 만들어보자.

이클립스에서 아래와 같이 두 개의 클래스를 만든다.

//TCPServerEx1
package Pack1;

public class TCPServerEx1 {

	public static void main(String[] args) {
		System.out.println( "시작" );
		
		System.out.println( "끝" );

	}
}


//TCPClientEx1
package Pack1;

public class TCPClientEx1 {

	public static void main(String[] args) {
		System.out.println( "시작" );
		
		System.out.println( "끝" );

	}
}

먼저 cmd창을 열고 작업할 이클립스의 워크스페이스 -> 패키지폴더 -> bin 폴더로 작업디렉토리를 설정한다.

명령어는 아래와 같다.

 

다시 서버 클래스를 아래와 같이 코딩한다.

package Pack1;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class TCPServerEx1 {

	public static void main(String[] args) {
		System.out.println( "시작" );
		
		ServerSocket serverSocket = null;
		Socket socket = null;
		
		try {
			//7777 서버 바인딩 포트 설정해서 서버 준비시키기
			serverSocket = new ServerSocket( 7777 );
			System.out.println( "서버가 준비되었습니다." );
			
			//클라이언트 연결하기
			socket = serverSocket.accept();
			System.out.println( "클라이언트가 연결되었습니다.");
			
		} catch (IOException e) {
			System.out.println( "[에러] : " + e.getMessage() );
			
		} finally {
			if ( socket != null ) try { socket.close(); } catch(IOException e) {}
			if ( serverSocket != null ) try { serverSocket.close(); } catch(IOException e) {}
		}
		
		System.out.println( "끝" );
	}
}

그리고 cmd창에서 TCPServer클래스를 실행시키면 서버가 준비된 상태로 대기된다.

그리고 클라이언트도 아래와 같이 만들어준다.

package Pack1;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

public class TCPClientEx1 {

	public static void main(String[] args) {
		System.out.println( "시작" );
		
		Socket socket = null;
		
		try {
        	//서버와 연결하기
			System.out.println( "서버와 연결중" );		
			socket = new Socket("localhost", 7777);
			System.out.println( "연결완료" );
			
		} catch (UnknownHostException e) {
			System.out.println( "[에러] : " + e.getMessage() );
		} catch (IOException e) {
			System.out.println( "[에러] : " + e.getMessage() );
		} finally {
			if ( socket != null ) try { socket.close(); } catch(IOException e) {}
		}
		
		System.out.println( "끝" );

	}
}

혹시라도 7777번 포트가 다른 곳에서 쓰이고 있으면 포트번호를 바꿔준다.

이제 TCPClientEx1를 이클립스에서 실행시키면 cmd창에서 대기시킨 서버가 클라이언트와 연결되고 종료된다.

만약에 서버대기상태에서 cmd 명령을 취소시키려면 ctrl + c를 누르면된다.

 

이번에 클라이언트가 서버에 접속시키고 데이터를 보내보자.

아래의 개념을 확인하자.

//TCPServerEx1
package Pack1;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class TCPServerEx1 {

	public static void main(String[] args) {
		System.out.println( "시작" );
		
		ServerSocket serverSocket = null;
		Socket socket = null;
		
		BufferedWriter bw = null;
		
		try {
			//7777 서버 바인딩 포트 설정해서 서버 준비시키기
			serverSocket = new ServerSocket( 7777 );
			System.out.println( "서버가 준비되었습니다." );
			
			//클라이언트 연결하기
			socket = serverSocket.accept();
			System.out.println( "클라이언트가 연결되었습니다.");
			
			//클라이언트가 접속하면 클라이언트에게 데이터 보내주기
			bw = new BufferedWriter( new OutputStreamWriter( socket.getOutputStream() ) );
			bw.write( "Hello Socket" + "\n" );		//엔터키를 붙여줘야 한다.
			
		} catch (IOException e) {
			System.out.println( "[에러] : " + e.getMessage() );
			
		} finally {
			if ( bw != null ) try { bw.close(); } catch(IOException e) {}
			if ( socket != null ) try { socket.close(); } catch(IOException e) {}
			if ( serverSocket != null ) try { serverSocket.close(); } catch(IOException e) {}
		}
		
		System.out.println( "끝" );

	}
}
//TCPClientEx1
package Pack1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.net.UnknownHostException;

public class TCPClientEx1 {

	public static void main(String[] args) {
		System.out.println( "시작" );
		
		Socket socket = null;
		BufferedReader br = null;
		
		
		try {
			System.out.println( "서버와 연결중" );		
			socket = new Socket("localhost", 7777);
			System.out.println( "연결완료" );
			
			//서버와 연결이되면 서버로부터 데이터 받고 출력하기
			br = new BufferedReader( new InputStreamReader( socket.getInputStream() ) );
			System.out.println( "MSG : " + br.readLine() );
			
			
		} catch (UnknownHostException e) {
			System.out.println( "[에러] : " + e.getMessage() );
		} catch (IOException e) {
			System.out.println( "[에러] : " + e.getMessage() );
		} finally {
			if ( br != null ) try { br.close(); } catch(IOException e) {}
			if ( socket != null ) try { socket.close(); } catch(IOException e) {}
		}
		
		System.out.println( "끝" );

	}
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
시작
서버와 연결중
연결완료
MSG : Hello Socket
끝

이때 중요한 것은 br을 닫아줄 때 socket보다 먼저 스트림을 닫아줘야 한다.

 

이번에는 클라이언트가 서버에게 문자열을 보내고 다시 서버로부터 받는 것을 만들어본다.

클라이언트와 서버 둘 다 input/output 스트림 두 개가 필요하다.

package Pack3;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class TCPServerEx1 {

	public static void main(String[] args) {
		System.out.println( "시작" );
		
		ServerSocket serverSocket = null;
		Socket socket = null;
		
		BufferedReader br = null;
		BufferedWriter bw = null;
		
		try {
			serverSocket = new ServerSocket( 7777 );
			System.out.println( "서버가 준비되었습니다." );
			
			socket = serverSocket.accept();
			System.out.println( "클라이언트가 연결되었습니다.");
			
			//input과 output 버퍼 문 열러주기
			br = new BufferedReader( new InputStreamReader( socket.getInputStream() ) );
			bw = new BufferedWriter( new OutputStreamWriter( socket.getOutputStream() ) );
			
			// echo : 받아온 것을 그대로 보내주는 것을 의미
			String msg = br.readLine();
			System.out.println( "client msg : " + msg );
			bw.write( msg + "\n" );
			System.out.println( "전송완료" );
			bw.flush();		//write 다음에는 flush()를 써줘야지 하나의 스트림이 끝났음을 알린다.
			
		} catch (IOException e) {
			System.out.println( "[에러] : " + e.getMessage() );
			
		} finally {
			if ( bw != null ) try { bw.close(); } catch(IOException e) {}
			if ( br != null ) try { br.close(); } catch(IOException e) {}
			if ( socket != null ) try { socket.close(); } catch(IOException e) {}
			if ( serverSocket != null ) try { serverSocket.close(); } catch(IOException e) {}
		}
		
		System.out.println( "끝" );

	}
}
package Pack3;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;

public class TCPClientEx1 {

	public static void main(String[] args) {
		System.out.println( "시작" );
		
		Socket socket = null;
		
		BufferedWriter bw = null;
		BufferedReader br = null;
		
		try {
			System.out.println( "서버와 연결중" );		
			socket = new Socket("localhost", 7777);
			System.out.println( "연결완료" );
			
			bw = new BufferedWriter( new OutputStreamWriter( socket.getOutputStream() ) );
			br = new BufferedReader( new InputStreamReader( socket.getInputStream() ) );
			
			bw.write( "Hello Server" + "\n");
			System.out.println( "전송완료" );
			bw.flush();	
			
			String msg = br.readLine();
			System.out.println( "MSG : " + msg);
			
			
		} catch (UnknownHostException e) {
			System.out.println( "[에러] : " + e.getMessage() );
		} catch (IOException e) {
			System.out.println( "[에러] : " + e.getMessage() );
		} finally {
			if ( bw != null ) try { bw.close(); } catch(IOException e) {}
			if ( br != null ) try { br.close(); } catch(IOException e) {}
			if ( socket != null ) try { socket.close(); } catch(IOException e) {}
		}
		
		System.out.println( "끝" );

	}
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
시작
서버와 연결중
연결완료
전송완료
MSG : Hello Server
끝

한글을 사용하려면 input/output 버퍼스트림을 열 때 아래와 같이 사용한다.

br = new BufferedReader( new InputStreamReader( socket.getInputStream(), "utf-8" ) );
bw = new BufferedWriter( new OutputStreamWriter( socket.getOutputStream(), "utf-8" ) );

 

문제 ) 클라이언트에서 서버로 단수 보내면 서버는 단수에 해당하는 구구단의 결과를 다시 클라이언트로

보내주는 프로그램 (5단을 출력해보자.)

 

1) 내 코드

//GugudanServer class

package Pack4;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class GugudanServer {

	public static void main(String[] args) {
		ServerSocket serverSocket = null;
		Socket socket = null;
		
		BufferedReader br = null;
		BufferedWriter bw = null;
		
		try {
			//서버만들기
			serverSocket = new ServerSocket( 7777 );
			System.out.println( "서버 준비 완료");
			
			//클라이언트 연결시키기
			socket = serverSocket.accept();
			System.out.println( "클라이언트 연결 완료" );
			
			//input/output 버퍼 통로 열어놓기
			br = new BufferedReader( new InputStreamReader( socket.getInputStream() ) );
			bw = new BufferedWriter( new OutputStreamWriter( socket.getOutputStream() ) );
			
			//입력받은 단수를 숫자로 바꾼 뒤 단수계산후 다시 문자열로 바꾸기
			String gugudan = br.readLine();
			System.out.println( "입력받은 단수 : " + gugudan );
			
			String result = "";
			int gugu = Integer.parseInt( gugudan );
			for( int i=1; i<=9; i++ ) {
				result += gugudan + " X " + i + " = " + String.valueOf(gugu*i) + "\n";
			}
			System.out.println( result );
			
			//계산된 결과값을 클라이언트에게 넘겨주기
			bw.write( result + "\n");
			System.out.println( "전송완료" );
			bw.flush();
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if ( bw != null ) try { bw.close(); } catch(IOException e) {}
			if ( br != null ) try { br.close(); } catch(IOException e) {}
			if ( socket != null ) try { socket.close(); } catch(IOException e) {}
			if ( serverSocket != null ) try { serverSocket.close(); } catch(IOException e) {}
		}
	}
}
//GugudanClient class

package Pack4;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;


public class GugudanClient {

	public static void main(String[] args) {
		Socket socket = null;
		
		BufferedWriter bw = null;
		BufferedReader br = null;
		
		try {
			//서버와 연결하기
			System.out.println( "서버와 연결중" );
			socket = new Socket( "localhost", 7777 );
			System.out.println( "서버 연결 완료" );
			
			//output/input 버퍼 스트림 통로 만들기
			bw = new BufferedWriter( new OutputStreamWriter( socket.getOutputStream() ) );
			br = new BufferedReader( new InputStreamReader( socket.getInputStream() ) );
			
			//서버에게 구구단 단수 넘기기
			bw.write("5" + "\n");
			System.out.println("전송 완료");
			bw.flush();
			
			//서버에서 구구단 단수 결과 받기
			System.out.println( "---결과 출력---");
			String gugudan = "";
			while( (gugudan = br.readLine()) != null ) {
				System.out.println( gugudan );
			}
			
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if ( br != null ) try { br.close(); } catch(IOException e) {}
			if ( bw != null ) try { bw.close(); } catch(IOException e) {}
			if ( socket != null ) try { socket.close(); } catch(IOException e) {}
		}
	}
}
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
서버와 연결중
서버 연결 완료
전송 완료
---결과 출력---
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
5 X 4 = 20
5 X 5 = 25
5 X 6 = 30
5 X 7 = 35
5 X 8 = 40
5 X 9 = 45

728x90
반응형
Comments