layout: true background-image: url(https://user-images.githubusercontent.com/6179259/60290723-50002480-9954-11e9-96fe-3fbd4d7d11d9.png) background-size: cover --- class: center, middle, title-slide ## R을 이용한 데이터 크롤링 ### <https://mrchypark.github.io/collect-data-with-r> #### [[의견 및 오류 신고]](https://github.com/mrchypark/collect-data-with-r/issues/new) ### 박찬엽 [<svg style="height:0.8em;top:.04em;position:relative;fill:#FF1B70;" viewBox="0 0 512 512"><path d="M256 8C118.941 8 8 118.919 8 256c0 137.059 110.919 248 248 248 48.154 0 95.342-14.14 135.408-40.223 12.005-7.815 14.625-24.288 5.552-35.372l-10.177-12.433c-7.671-9.371-21.179-11.667-31.373-5.129C325.92 429.757 291.314 440 256 440c-101.458 0-184-82.542-184-184S154.542 72 256 72c100.139 0 184 57.619 184 160 0 38.786-21.093 79.742-58.17 83.693-17.349-.454-16.91-12.857-13.476-30.024l23.433-121.11C394.653 149.75 383.308 136 368.225 136h-44.981a13.518 13.518 0 0 0-13.432 11.993l-.01.092c-14.697-17.901-40.448-21.775-59.971-21.775-74.58 0-137.831 62.234-137.831 151.46 0 65.303 36.785 105.87 96 105.87 26.984 0 57.369-15.637 74.991-38.333 9.522 34.104 40.613 34.103 70.71 34.103C462.609 379.41 504 307.798 504 232 504 95.653 394.023 8 256 8zm-21.68 304.43c-22.249 0-36.07-15.623-36.07-40.771 0-44.993 30.779-72.729 58.63-72.729 22.292 0 35.601 15.241 35.601 40.77 0 45.061-33.875 72.73-58.161 72.73z"/></svg>][mail] [<svg style="height:0.8em;top:.04em;position:relative;fill:#FF1B70;" viewBox="0 0 264 512"><path d="M76.7 512V283H0v-91h76.7v-71.7C76.7 42.4 124.3 0 193.8 0c33.3 0 61.9 2.5 70.2 3.6V85h-48.2c-37.8 0-45.1 18-45.1 44.3V192H256l-11.7 91h-73.6v229"/></svg>][fb] [<svg style="height:0.8em;top:.04em;position:relative;fill:#FF1B70;" viewBox="0 0 496 512"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>][github] ### .small[2019년 5월 31일] .tiny[update 2019년 7월 27일] --- class: split-50 .column[.content.vmiddle.right[ ![](https://avatars2.githubusercontent.com/u/6179259?v=4&s=460) ]] .column[.content.left[ <br> ### 박찬엽 - .yellow[(현)] SK Telecome AI센터 AI Product DevOps팀 - .yellow[(현)] 팟캐스트 데이터홀릭 .blue[박박사] - .gray[(전)]코빗 재무팀 데이터 담당자 * 재무DB 구축/관리 및 자동화 - .gray[(전)]서울도시가스 선행연구팀 연구원 * 챗봇 엔진 개발 및 서버 구축 - .gray[(전)]2017년 패스트 캠퍼스 데이터 분석 R 강의 * [데이터 분석을 위한 중급 R 프로그래밍](http://www.fastcampus.co.kr/data_camp_dabrp/) - [ForkonLP](https://forkonlp.github.io/) 프로젝트 오너 * N사 뉴스 크롤러 [N2H4](https://github.com/forkonlp/N2H4), D사 뉴스 크롤러 [DNH4](https://github.com/forkonlp/DNH4) - .blue[**FACEBOOK**]@[mrchypark](https://www.facebook.com/mrchypark) - .gray[**GITHUB**]@[mrchypark](https://github.com/mrchypark) ]] --- class: center, middle, title-slide ## .pen-p[R과 Rstudio 설치] --- ## 설치를 위한 다운로드 아래 두 링크에 들어가서 각 운영체제에 맞는 파일을 다운받아 설치해주세요. - R: <https://cloud.r-project.org/> - Rstudio: <https://www.rstudio.com/products/rstudio/download/#download> ## 크롤링에 대한 참고 자료 - 데이터홀릭 팟케스트 <http://www.podbbang.com/ch/1771386> - 크롤링 특집: 9화 (2019년 6월 3일), 10화 (2019년 6월 10일) - 크롤링 영상 강의 <https://youtu.be/Me0bvPo9KUc> - 중앙일보 크롤링 코드 예시 <https://github.com/mrchypark/joins_crawler> --- class: center, middle, title-slide ## .pen-p[R로 웹 데이터를 가져오는 방법] --- class: center, middle, title-slide ## 웹에 있는 데이터를 가져오는 단계 ### 요청 - 추출 - 저장 ### 반복 - 예외처리 - 최적화 --- ## 관련 R 패키지 및 함수 #### - 요청 : curl, httr, rvest, RSelenium #### - 정리 : 정규표현식, jsonlite, rvest #### - 저장 : write.*() #### - 반복 : for, parallel #### - 예외처리 : try, if #### - 최적화 : profvis, microbenchmark --- ## 관련 R 패키지 및 함수 #### **- 요청 : curl, httr, rvest, RSelenium** #### **- 정리 : 정규표현식, jsonlite, rvest** #### - .gray[저장 : write.*()] #### - .gray[반복 : for, parallel] #### - .gray[예외처리 : try, if] #### - .gray[최적화 : profvis, microbenchmark] --- class: center, middle, title-slide ## 오늘 이야기 할 것 ### 요청(4가지)과 정리 ### .gray[메인과 에피타이저] --- class: center, middle, title-slide ## 그럼 에피타이저 먼저! --- ## 서버가 하는 것 .pull-left[ 외부에서 요청하면 규칙대로 정보를 제공하는 것 ] .pull-right[ ![](https://pbs.twimg.com/profile_images/581161893219323904/eGnWc30X.png) ] --- ## 브라우저가 하는 것 .pull-left[ 서버가 주는 것들을 사용자에게 보여주는 것 ] .pull-right[ ![](https://cdn.dribbble.com/users/107490/screenshots/2384364/icon-cloud-06_1x.png) ] --- ## 웹 서버가 우리에게 주는 것 text(html, css, js, etc), image. 브라우저가 약속된 모양으로 우리에게 보여줌. .pull-center[.set[ ![](https://qph.ec.quoracdn.net/main-qimg-1f99b9ce08edd2309efff97b710ffcbe) ]] --- ## 실제로 브라우저가 받는 파일들 .pull-center[.half[ ![](https://raw.githubusercontent.com/mrchypark/getWebR/master/img/source.png) ]] --- class: center, middle, title-slide ## * 그럼 web api는 뭔가? web으로 제공되는 Application Programming Interface 함수인데 외부 서버에서 동작하여 웹 기술로 결과를 받는 것 --- ## 우리가 필요한 것 text(html) 중 일부만(ex>제목) ![](https://raw.githubusercontent.com/mrchypark/getWebR/master/img/title.png) --- class: center, middle, title-slide ### 그럼 이제 정리(에피타이저)를 설명 #### .blue[html 문서안에 글자 중 필요한 것만 가져오기] --- class: center, middle, title-slide #### 1번 글자를 다루는 강력한 방법 : 정규표현식 하지만 어려움 ### 2번 xml의 node를 다루는 패키지 : rvest --- class: center, middle, title-slide 정규표현식은 [검색](https://www.google.co.kr/search?q=%EC%A0%95%EA%B7%9C%ED%91%9C%ED%98%84%EC%8B%9D&oq=%EC%A0%95%EA%B7%9C%ED%91%9C%ED%98%84%EC%8B%9D&aqs=chrome..69i57j69i61.2391j0j7&sourceid=chrome&ie=UTF-8)해보세요. r에서는 [stringr](https://github.com/tidyverse/stringr) 이라는 서포트 패키지가 있음. --- class: center, middle, title-slide ## [rvest](https://github.com/hadley/rvest) ### node, attr, text만 기억하면 됨. --- ## node란 html에서 tag라고 불리는 것. .pull-center[.ori[ ![](https://lh3.googleusercontent.com/SSAbYW6kAM728XuKv3PK5Uhgva0ueIBDnoGhPkou6lp9QYgDVwRFivfQNgORT8FT5js4gBFezjSvZlqujcbWup6yXvRTkEOkMotawSPcaOpc9dQvyVP05ODEFw) ]] --- ## 그럼 html 이란 [xml](https://ko.wikipedia.org/wiki/XML)양식으로 작성된 웹 브라우저들이 이해하는 표준 문서 .pull-center[.ori[ ![](https://lh3.googleusercontent.com/az75sycVUFHD0aIKUmCZrs_Nf3-LCxiHSsYUZ_z5umiHK3XX77f1A6vCCD7YZYQNOAploEFjMYcu9x-DxRe5JdqZGFsnA3FhCvO3pRNBsK5M50RgzKd0hrx2gg) ]] --- ## attr 이란 attr은 attribute의 줄임으로 아래 예시로 tag의 attr1은 example1 임 ```{} <tag attr1="example1" attr2="example2"> 안녕하세요 </tag> ``` --- #### 원하는 글자가 있는 노드를 지정하기 위해서 [css 선택자](http://www.nextree.co.kr/p8468/)를 공부해야 함. -- #### css 선택자가 동작하는 방식 1. tag 이름 2. tag의 id 속성 3. tag의 class 속성 4. tag의 custom 속성 -- #### css 선택자로 node를 선택하기 위해서 1. `tag` 1. `#id` 1. `.class` 1. `[attr="val"]` 1. `tag#id` 1. `tag.class` 1. `tag[attr="val"]` --- ## text 이란 text은 시작 태그와 종료 태그 사이에 있는 글자로, 아래 예시 기준 "안녕하세요" 를 뜻함 ```{} <tag attr1="example1" attr2="example2"> 안녕하세요 </tag> ``` --- ## rvest의 동작 순서(text 가져오기) 1. html 문서 데이터 가져오기 1. 필요한 노드 선택하기 1. 노드내에 text를 가져오기 ### rvest 함수 ```{} read_html(url) read_html(url) %>% html_nodes("tag.class") read_html(url) %>% html_nodes("tag.class") %>% html_text ``` --- ## rvest의 동작 순서(attr 가져오기) 1. html 문서 데이터 가져오기 1. 필요한 노드 선택하기 1. 노드내에 attr 중에 "attr1"값을 가져오기 ### rvest 함수 ```{} read_html(url) read_html(url) %>% html_nodes("tag.class") read_html(url) %>% html_nodes("tag.class") %>% html_attr("attr1") ``` --- ## 예시 ```r library(rvest) url <- "https://news.naver.com/main/hotissue/read.nhn?mid=hot&sid1=100&cid=1079165&iid=2975770&oid=001&aid=0010571037&ptype=052" nv <- read_html(url) ``` ``` ## Loading required package: xml2 ``` ``` ## {html_document} ## <html lang="ko"> ## [1] <head>\n<meta http-equiv="Content-Type" content="text/html; charset= ... ## [2] <body>\r\n<div id="wrap">\r\n\t\r\n\t<div id="da_base"></div>\r\n\t< ... ``` ```r nvns <- html_nodes(nv, "h3#articleTitle") ``` ``` ## {xml_nodeset (1)} ## [1] <h3 id="articleTitle">'깜짝 방중' 김정은, 中과 조율 마치고 美와 대화 본격 나서나</h3> ``` .pull-left[ ```r title <- html_text(nvns) ``` ``` ## [1] "'깜짝 방중' 김정은, 中과 조율 마치고 美와 대화 본격 나서나" ``` ] .pull-right[ ```r id <- html_attr(nvns, "id") ``` ``` ## [1] "articleTitle" ``` ] --- class: center, middle, title-slide rvest는 html 문서로 되어 있는 웹에서의 텍스트 데이터를 가져와서 처리하는 패키지 --- class: center, middle, title-slide ## 이제 메인! 요청하기 ### (read_html이 방법 1 ㄷㄷㄷ) --- class: center, middle, title-slide ### 그래서 우리가 알아야 할 것 ## GET과 POST --- class: center, middle, title-slide 방금 read_html 함수는 GET 방식으로 서버에 요청하여 html 문서를 받은 것. --- class: center, middle, title-slide http 표준 요청을 수행해 주는 [httr](https://github.com/r-lib/httr) 패키지 --- ## GET 요청 read_html(url) == content(GET(url)) 인걸로 GET 요청으로 html 문서를 가져올 때는 read_html()함수가 함께 처리해줌. ```r library(httr) library(rvest) url <- "http://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=102&oid=437&aid=0000165410" dat <- GET(url) content(dat) ``` ``` ## {html_document} ## <html lang="ko"> ## [1] <head>\n<meta http-equiv="Content-Type" content="text/html; charset= ... ## [2] <body>\r\n<div id="wrap">\r\n\t\r\n\t<div id="da_base"></div>\r\n\t< ... ``` ```r read_html(url) ``` ``` ## {html_document} ## <html lang="ko"> ## [1] <head>\n<meta http-equiv="Content-Type" content="text/html; charset= ... ## [2] <body>\r\n<div id="wrap">\r\n\t\r\n\t<div id="da_base"></div>\r\n\t< ... ``` --- class: center, middle, title-slide ## 왜 GET 함수를 써야 하는가 header, cookie 등 다양한 옵션을 사용할 수 있음. ex> 크롤러가 아니라고 속여야 한다던가.... --- class: center, middle, title-slide ### 그럼 POST 란? --- ## POST 란 body에 사용자가 필요한 값을 추가해서 요청을 할 수 있는 방법 .pull-left[ ```r res <- GET(url = '필요한 인터넷 주소') ``` ] .pull-right[ ```r bodys <- list(여기에 데이터가 들어갑니다.) res <- POST(url = '필요한 인터넷 주소', body = bodys) ``` ] --- ## 사용할 api 네이버 파파고 번역 api <https://developers.naver.com/products/nmt/> 인공 신경망으로 한영 번역을 진행해 줌 --- ## 네이버 개발자센터에서 본인 등록 [네이버 개발자센터](https://developers.naver.com/main/) ![](https://raw.githubusercontent.com/MrKevinNa/MrKevinNa.github.io/master/images/2019-04-17-Naver-Papago-API를-활용한-NMT-번역/Naver_API_01.png) --- ## 단계 **Application** > **계정 설정**을 클릭하여 본인인증 ![](https://raw.githubusercontent.com/MrKevinNa/MrKevinNa.github.io/master/images/2019-04-17-Naver-Papago-API를-활용한-NMT-번역/Naver_API_02.png) --- ## 어플리케이션 등록 **사용 API**는 **Papago NMT 번역**을 선택 ![](https://user-images.githubusercontent.com/6179259/56791074-29811880-6841-11e9-9e0d-b3a89df9be0e.png) --- ## 서비스 환경 **WEB 설정** 선택, **http://naver.com** 입력 ![](https://user-images.githubusercontent.com/6179259/56791143-4fa6b880-6841-11e9-8968-68e398cc2fb6.png) --- ## api key 발급 **Client ID**와 **Client Secret** 을 잘 보관 ![](https://user-images.githubusercontent.com/6179259/56791378-e6737500-6841-11e9-977b-7091073cbe5d.png) --- ## api key 등록 ```r install.packages("usethis") library(usethis) edit_r_environ() ``` ![](https://user-images.githubusercontent.com/6179259/56792778-546d6b80-6845-11e9-875d-f2065fd816b9.png) --- ## 등록 상태 확인 `.Renviron` 파일을 저장한 후 Rstudio 를 재시작 ```r Sys.getenv('NAVER_CLIENT_ID') Sys.getenv('NAVER_CLIENT_SECRET') ``` --- ## 개발가이드 확인 <https://developers.naver.com/docs/papago/> ## body 란 list() 자료형으로 되어 있고 이름이 있는 데이터로 만든 요청에 추가할 수 있는 값 ```r string <- '오늘 주제는 언론인을 위한 R 을 이용한 데이터 크롤링입니다.' bodys <- list(source = 'ko', target = 'en', text = string) ``` --- ## PUST 요청 네이버의 인증을 통한 서비스를 진행하므로 header 정보를 추가함 ```r library(httr) ah <- add_headers('X-Naver-Client-Id' = Sys.getenv('NAVER_CLIENT_ID'), 'X-Naver-Client-Secret' = Sys.getenv('NAVER_CLIENT_SECRET')) res <- POST(url = 'https://openapi.naver.com/v1/papago/n2mt', encode = 'json', body = bodys, config = ah) ``` --- ## content() 함수 httr 패키지의 요청들은 read_html() 함수와 달리 header 나 cookie 등의 모든 정보를 다 확인할 수 있음. 그래서 응답으로 서버가 데이터로써 준 내용을 확인하기 위해서 content() 함수를 제공함. ```r content(res) ``` ``` ## $errorMessage ## [1] "Not Exist Client ID : Authentication failed. (인증에 실패했습니다.)" ## ## $errorCode ## [1] "024" ``` --- ## PUST 요청 결과 확인 `list()` 자료형 내부에 필요한 데이터만 가져 옴 ```r content(res)$message$result$translatedText ``` ``` ## NULL ``` --- class: center, middle, title-slide 여기까지가 http 요청을 따라하는 httr 패키지(방법 2) --- class: center, middle, title-slide ## 중간 정산 이제 정적 웹 서비스내의 글자와 web api 데이터를 가져오는 2가지 방법을 알게 됨. --- class: center, middle, title-slide ## 이제 필요한 것 ### 동적 웹 서비스에서 가져오기 --- ## 동적 웹 서비스란 javascript<sup>1</sup>가 웹페이지 동작을 조절하는 것. .pull-center[.set[ ![](https://qph.ec.quoracdn.net/main-qimg-1f99b9ce08edd2309efff97b710ffcbe) ]] .footnote[ [1] [javascript](https://ko.wikipedia.org/wiki/%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8) : 브라우저에서 동작하는 개발 언어로 동적 웹 서비스를 개발하는 목적으로 많이 사용함. ] --- ## 그래서 브라우저가 필요함 동적 웹 서비스내의 데이터는 브라우저가 처리해준 결과이기 때문에 브라우저와 같이 처리하는 방법을 찾던지, 브라우저를 사용하던지 해야 함. --- class: center, middle, title-slide ## [RSelenium](https://github.com/ropensci/RSelenium) --- ## Selenium 이란 Selenium은 코드로 브라우저를 컨트롤하는 패키지. 그래서 브라우저를 움직일 수 있다! 그걸 R에서 사용하는 [RSelenium 패키지](https://github.com/ropensci/RSelenium)를 사용할 예정 .pull-center[.ori[ ![](https://2.bp.blogspot.com/-idwhrEvGRcM/WAhO0w9TwnI/AAAAAAAAAGU/xThZWzPBrfIiz_RbcIk4CTwrpZiVJayFgCLcB/s320/Selenium.jpg) ]] --- class: center, middle, title-slide ## 어떤 브라우저를 사용할까? ## [phantomjs](http://phantomjs.org/) --- ## phantonjs 란 phantomjs는 headless 브라우저로 headless란 사람이 보는 부분이 없는 것 .pull-center[.ori[ ![](http://phantomjs.org/img/phantomjs-logo.png) ]] .footnote[ * 최근 chrome도 headless를 자체적으로 지원하기 시작함. ] --- ## 실행 ```r library(RSelenium) pJS <- wdman::phantomjs(port = 4567L) ``` ``` ## checking phantomjs versions: ## BEGIN: PREDOWNLOAD ## BEGIN: DOWNLOAD ## BEGIN: POSTDOWNLOAD ``` ```r remDr <- remoteDriver(port = 4567L, browserName = 'phantomjs') remDr$open() ``` ``` ## [1] "Connecting to remote server" ## $browserName ## [1] "phantomjs" ## ## $version ## [1] "2.1.1" ## ## $driverName ## [1] "ghostdriv ``` --- ## 실행 ```r remDr$navigate("http://www.google.com/ncr") remDr$getTitle()[[1]] ``` ``` ## [1] "Google" ``` ```r remDr$close() pJS$stop() ``` ``` ## [1] TRUE ``` --- ## 시연 키 입력과 마우스 클릭을 확인 [시연코드 가기](https://raw.githubusercontent.com/mrchypark/getWebR/master/RSelenium.R) --- class: center, middle, title-slide RSelenium이란 브라우저를 컨트롤하는 패키지(방법 3) --- class: center, middle, title-slide 마지막으로... --- ## +고급 크롬 개발자 도구를 이용하면 js가 가져오는 api를 찾아서 더 빠르게 정보를 가져올 수 있음 ![](https://raw.githubusercontent.com/mrchypark/getWebR/master/img/comment.png) --- ## GET 요청 찾아낸 주소에 GET() 요청을 시도함(은 실패). 이런 웹 서비스 내에서 사용하는 api의 경우 OpenAPI 가 아니기 때문에 설명서 없고, 다양한 시도를 통해서 사용법을 찾아야 함. ```r url<-"https://apis.naver.com/commentBox/cbox/web_naver_list_jsonp.json?ticket=news&templateId=view_society&pool=cbox5&_callback=jQuery1707377572341505474_1508264183038&lang=ko&country=&objectId=news437%2C0000165410&categoryId=&pageSize=10&indexSize=10&groupId=&listType=OBJECT&page=1&sort=new&includeAllStatus=true&_=1508264264524" con <- httr::GET(url) tt <- httr::content(con, "text") tt ``` ``` ## [1] "jQuery1707377572341505474_1508264183038({\"success\":false,\"code\":\"3999\",\"message\":\"잘못된 접근입니다.\",\"lang\":\"ko\",\"country\":\"UNKNOWN\",\"result\":{},\"date\":\"2019-08-27T00:34:50+0000\"});" ``` --- ## 추가 정보 제공 네이버 뉴스 댓글의 경우, referer라는 정보가 요청 header에 있어야만 정상 동작함 ```r url<-"https://apis.naver.com/commentBox/cbox/web_naver_list_jsonp.json?ticket=news&templateId=view_society&pool=cbox5&_callback=jQuery1707377572341505474_1508264183038&lang=ko&country=&objectId=news437%2C0000165410&categoryId=&pageSize=10&indexSize=10&groupId=&listType=OBJECT&page=1&sort=new&includeAllStatus=true&_=1508264264524" ref<-"http://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=102&oid=437&aid=0000165410" con <- httr::GET(url, httr::add_headers(Referer = ref)) tt <- httr::content(con, "text") tt ``` ``` ## [1] "jQuery1707377572341505474_1508264183038({\"success\":true,\"code\":\"1000\",\"message\":\"요청을 성공적으로 처리하였습니다.\",\"lang\":\"ko\",\"country\":\"UNKNOWN\",\"result\":{\"commentList\":[{\"ticket\":\"news\",\"objectId\":\"news437,0000165410\",\"categoryId\":\"*\",\"templateId\":\"view_society\",\"commentNo\":1099281045,\"parentCommentNo\":1099281045,\"replyLevel\":1,\"replyCount\":0,\"replyAllCount\":0,\"replyPreviewNo\":null,\"replyList\":null,\"imageCount\":0,\"imageList\":null,\"imagePathList\":null,\"imageWidthList\":null,\"imageHeightList\":null,\"commentType\":\"txt\",\"stickerId\":null,\"sticker\":null,\"sortValue\":1508285910732,\"contents\":\"드라마세트장같은건 시간이 지나면 서서히 시들게 되있음 그럼 거기다 돈을 투자할려면 장기적으로 보고 후에 다른 컨텐츠를 확보해서 유지할 생각을 해야되는데 아무도 그런생각을 안함. 그런 상황도 모르고 지차체에서 돈퍼줄 생각을 한 사람도 잘라야됨\",\"userIdNo\":\"\",\"exposedUserIp\":null,\"lang\":\"ko\",\"country\":\"KR\",\"idType\":\"naver\",\"idProvider\":\"naver\",\"userName\":\"k1_h****\",\"userProfileImage\":\"\",\"profileType\":\"naver\",\"modTime\":\"2017-10-18T09:18:30+0900\",\"modTimeGmt\":\"2017-10-18T00:18:30+0000\",\"regTime\":\"2017-10-18T09:18:30+0900\",\"regTimeGmt\":\"2017-10-18T00:18:30+0000\",\"sympathyCount\":1,\"antipathyCount\":1,\"userBlind\":false,\"hideReplyButton\":false,\"status\":0,\"mine\":false,\"best\":false,\"mentions\":null,\"toUser\":null,\"userStatus\":0,\"categoryImage\":null,\"open\":false,\"levelCode\":null,\"grades\":null,\"sympathy\":false,\"antipathy\":false,\"snsList\":null,\"metaInfo\":null,\"extension\":null,\"audioInfoList\":null,\"translation\":null,\"report\":null,\"middleBlindReport\":false,\"spamInfo\":null,\"userHomepageUrl\":null,\"defamation\":false,\"hiddenByCleanbot\":false,\"visible\":true,\"serviceId\":null,\"idNo\":\"\",\"manager\":false,\"deleted\":false,\"blindReport\":false,\"anonymous\":false,\"expose\":true,\"exposeByCountry\":false,\"virtual\":false,\"secret\":false,\"blind\":false,\"profileUserId\":null,\"containText\":true,\"maskedUserId\":\"k1_h****\",\"maskedUserName\":\"k1****\",\"validateBanWords\":false},{\"ticket\":\"news\",\"objectId\":\"news437,0000165410\",\"categoryId\":\"*\",\"templateId\":\"view_society\",\"commentNo\":1099270075,\"parentCommentNo\":1099270075,\"replyLevel\":1,\"replyCount\":0,\"replyAllCount\":0,\"replyPreviewNo\":null,\"replyList\":null,\"imageCount\":0,\"imageList\":null,\"imagePathList\":null,\"imageWidthList\":null,\"imageHeightList\":null,\"commentType\":\"txt\",\"stickerId\":\"\",\"sticker\":null,\"sortValue\":1508284825689,\"contents\":\"\",\"userIdNo\":\"\",\"exposedUserIp\":null,\"lang\":\"ko\",\"country\":\"KR\",\"idType\":\"naver\",\"idProvider\":\"naver\",\"userName\":\"ultr****\",\"userProfileImage\":\"\",\"profileType\":\"naver\",\"modTime\":\"2017-10-22T17:31:25+0900\",\"modTimeGmt\":\"2017-10-22T08:31:25+0000\",\"regTime\":\"2017-10-18T09:00:25+0900\",\"regTimeGmt\":\"2017-10-18T00:00:25+0000\",\"sympathyCount\":0,\"antipathyCount\":0,\"userBlind\":false,\"hideReplyButton\":false,\"status\":1,\"mine\":false,\"best\":false,\"mentions\":null,\"toUser\":null,\"userStatus\":null,\"categoryImage\":null,\"open\":false,\"levelCode\":null,\"grades\":null,\"sympathy\":false,\"antipathy\":false,\"snsList\":null,\"metaInfo\":null,\"extension\":null,\"audioInfoList\":null,\"translation\":null,\"report\":null,\"middleBlindReport\":false,\"spamInfo\":null,\"userHomepageUrl\":null,\"defamation\":false,\"hiddenByCleanbot\":false,\"visible\":false,\"serviceId\":null,\"idNo\":\"\",\"manager\":false,\"deleted\":true,\"blindReport\":false,\"anonymous\":false,\"expose\":false,\"exposeByCountry\":false,\"virtual\":false,\"secret\":false,\"blind\":false,\"profileUserId\":null,\"containText\":true,\"maskedUserId\":\"ultr****\",\"maskedUserName\":\"ul****\",\"validateBanWords\":false},{\"ticket\":\"news\",\"objectId\":\"news437,0000165410\",\"categoryId\":\"*\",\"templateId\":\"default_society\",\"commentNo\":1099269365,\"parentCommentNo\":1099269365,\"replyLevel\":1,\"replyCount\":0,\"replyAllCount\":0,\"replyPreviewNo\":null,\"replyList\":null,\"imageCount\":0,\"imageList\":null,\"imagePathList\":null,\"imageWidthList\":null,\"imageHeightList\":null,\"commentType\":\"txt\",\"stickerId\":null,\"sticker\":null,\"sortValue\":1508284760064,\"contents\":\"관리와 꾸준한 홍보 했음 이리 허물겠어? 주민들도 그래 지들이 관광객 받을 생각이였음 누워서 떡먹을 생각말고 지들끼리라도 발전시켰어야지\",\"userIdNo\":\"\",\"exposedUserIp\":null,\"lang\":\"ko\",\"country\":\"KR\",\"idType\":\"naver\",\"idProvider\":\"naver\",\"userName\":\"tkfk****\",\"userProfileImage\":\"\",\"profileType\":\"naver\",\"modTime\":\"2017-10-18T08:59:20+0900\",\"modTimeGmt\":\"2017-10-17T23:59:20+0000\",\"regTime\":\"2017-10-18T08:59:20+0900\",\"regTimeGmt\":\"2017-10-17T23:59:20+0000\",\"sympathyCount\":0,\"antipathyCount\":0,\"userBlind\":false,\"hideReplyButton\":false,\"status\":0,\"mine\":false,\"best\":false,\"mentions\":null,\"toUser\":null,\"userStatus\":0,\"categoryImage\":null,\"open\":false,\"levelCode\":null,\"grades\":null,\"sympathy\":false,\"antipathy\":false,\"snsList\":null,\"metaInfo\":null,\"extension\":null,\"audioInfoList\":null,\"translation\":null,\"report\":null,\"middleBlindReport\":false,\"spamInfo\":null,\"userHomepageUrl\":null,\"defamation\":false,\"hiddenByCleanbot\":false,\"visible\":true,\"serviceId\":null,\"idNo\":\"\",\"manager\":false,\"deleted\":false,\"blindReport\":false,\"anonymous\":false,\"expose\":true,\"exposeByCountry\":false,\"virtual\":false,\"secret\":false,\"blind\":false,\"profileUserId\":null,\"containText\":true,\"maskedUserId\":\"tkfk****\",\"maskedUserName\":\"tk****\",\"validateBanWords\":false},{\"ticket\":\"news\",\"objectId\":\"news437,0000165410\",\"categoryId\":\"*\",\"templateId\":\"view_society\",\"commentNo\":1099268805,\"parentCommentNo\":1099268805,\"replyLevel\":1,\"replyCount\":0,\"replyAllCount\":0,\"replyPreviewNo\":null,\"replyList\":null,\"imageCount\":0,\"imageList\":null,\"imagePathList\":null,\"imageWidthList\":null,\"imageHeightList\":null,\"commentType\":\"txt\",\"stickerId\":\"\",\"sticker\":null,\"sortValue\":1508284712984,\"contents\":\"\",\"userIdNo\":\"\",\"exposedUserIp\":null,\"lang\":\"ko\",\"country\":\"KR\",\"idType\":\"naver\",\"idProvider\":\"naver\",\"userName\":\"thet****\",\"userProfileImage\":\"\",\"profileType\":\"naver\",\"modTime\":\"2017-10-18T19:10:28+0900\",\"modTimeGmt\":\"2017-10-18T10:10:28+0000\",\"regTime\":\"2017-10-18T08:58:32+0900\",\"regTimeGmt\":\"2017-10-17T23:58:32+0000\",\"sympathyCount\":0,\"antipathyCount\":0,\"userBlind\":false,\"hideReplyButton\":false,\"status\":1,\"mine\":false,\"best\":false,\"mentions\":null,\"toUser\":null,\"userStatus\":null,\"categoryImage\":null,\"open\":false,\"levelCode\":null,\"grades\":null,\"sympathy\":false,\"antipathy\":false,\"snsList\":null,\"metaInfo\":null,\"extension\":null,\"audioInfoList\":null,\"translation\":null,\"report\":null,\"middleBlindReport\":false,\"spamInfo\":null,\"userHomepageUrl\":null,\"defamation\":false,\"hiddenByCleanbot\":false,\"visible\":false,\"serviceId\":null,\"idNo\":\"\",\"manager\":false,\"deleted\":true,\"blindReport\":false,\"anonymous\":false,\"expose\":false,\"exposeByCountry\":false,\"virtual\":false,\"secret\":false,\"blind\":false,\"profileUserId\":null,\"containText\":true,\"maskedUserId\":\"thet****\",\"maskedUserName\":\"th****\",\"validateBanWords\":false},{\"ticket\":\"news\",\"objectId\":\"news437,0000165410\",\"categoryId\":\"*\",\"templateId\":\"view_society\",\"commentNo\":1099257875,\"parentCommentNo\":1099257875,\"replyLevel\":1,\"replyCount\":0,\"replyAllCount\":0,\"replyPreviewNo\":null,\"replyList\":null,\"imageCount\":0,\"imageList\":null,\"imagePathList\":null,\"imageWidthList\":null,\"imageHeightList\":null,\"commentType\":\"txt\",\"stickerId\":null,\"sticker\":null,\"sortValue\":1508283563049,\"contents\":\"임기내에 뭔가 보이는 업적 쌓아보겠다고 이것저것 많이 쳐 만드는데 막상 시간지나면 쓸데없어진게 대다수고 그런데서 세금 줄줄 다 새지. 시공업체 뇌물 받아먹기도 안성맞춤\",\"userIdNo\":\"\",\"exposedUserIp\":null,\"lang\":\"ko\",\"country\":\"KR\",\"idType\":\"naver\",\"idProvider\":\"naver\",\"userName\":\"tu17****\",\"userProfileImage\":\"\",\"profileType\":\"naver\",\"modTime\":\"2017-10-18T08:39:23+0900\",\"modTimeGmt\":\"2017-10-17T23:39:23+0000\",\"regTime\":\"2017-10-18T08:39:23+0900\",\"regTimeGmt\":\"2017-10-17T23:39:23+0000\",\"sympathyCount\":1,\"antipathyCount\":0,\"userBlind\":false,\"hideReplyButton\":false,\"status\":0,\"mine\":false,\"best\":false,\"mentions\":null,\"toUser\":null,\"userStatus\":0,\"categoryImage\":null,\"open\":false,\"levelCode\":null,\"grades\":null,\"sympathy\":false,\"antipathy\":false,\"snsList\":null,\"metaInfo\":null,\"extension\":null,\"audioInfoList\":null,\"translation\":null,\"report\":null,\"middleBlindReport\":false,\"spamInfo\":null,\"userHomepageUrl\":null,\"defamation\":false,\"hiddenByCleanbot\":false,\"visible\":true,\"serviceId\":null,\"idNo\":\"\",\"manager\":false,\"deleted\":false,\"blindReport\":false,\"anonymous\":false,\"expose\":true,\"exposeByCountry\":false,\"virtual\":false,\"secret\":false,\"blind\":false,\"profileUserId\":null,\"containText\":true,\"maskedUserId\":\"tu17****\",\"maskedUserName\":\"tu****\",\"validateBanWords\":false},{\"ticket\":\"news\",\"objectId\":\"news437,0000165410\",\"categoryId\":\"*\",\"templateId\":\"view_society\",\"commentNo\":1099246205,\"parentCommentNo\":1099246205,\"replyLevel\":1,\"replyCount\":0,\"replyAllCount\":0,\"replyPreviewNo\":null,\"replyList\":null,\"imageCount\":0,\"imageList\":null,\"imagePathList\":null,\"imageWidthList\":null,\"imageHeightList\":null,\"commentType\":\"txt\",\"stickerId\":null,\"sticker\":null,\"sortValue\":1508282463113,\"contents\":\"그래서 다스는 누구껀가요?\",\"userIdNo\":\"\",\"exposedUserIp\":null,\"lang\":\"ko\",\"country\":\"KR\",\"idType\":\"naver\",\"idProvider\":\"naver\",\"userName\":\"proh****\",\"userProfileImage\":\"\",\"profileType\":\"naver\",\"modTime\":\"2017-10-18T08:21:03+0900\",\"modTimeGmt\":\"2017-10-17T23:21:03+0000\",\"regTime\":\"2017-10-18T08:21:03+0900\",\"regTimeGmt\":\"2017-10-17T23:21:03+0000\",\"sympathyCount\":1,\"antipathyCount\":1,\"userBlind\":false,\"hideReplyButton\":false,\"status\":0,\"mine\":false,\"best\":false,\"mentions\":null,\"toUser\":null,\"userStatus\":0,\"categoryImage\":null,\"open\":true,\"levelCode\":null,\"grades\":null,\"sympathy\":false,\"antipathy\":false,\"snsList\":null,\"metaInfo\":null,\"extension\":null,\"audioInfoList\":null,\"translation\":null,\"report\":null,\"middleBlindReport\":false,\"spamInfo\":null,\"userHomepageUrl\":null,\"defamation\":false,\"hiddenByCleanbot\":false,\"visible\":true,\"serviceId\":null,\"idNo\":\"\",\"manager\":false,\"deleted\":false,\"blindReport\":false,\"anonymous\":false,\"expose\":true,\"exposeByCountry\":false,\"virtual\":false,\"secret\":false,\"blind\":false,\"profileUserId\":null,\"containText\":true,\"maskedUserId\":\"proh****\",\"maskedUserName\":\"pr****\",\"validateBanWords\":false},{\"ticket\":\"news\",\"objectId\":\"news437,0000165410\",\"categoryId\":\"*\",\"templateId\":\"view_society\",\"commentNo\":1099243595,\"parentCommentNo\":1099243595,\"replyLevel\":1,\"replyCount\":0,\"replyAllCount\":0,\"replyPreviewNo\":null,\"replyList\":null,\"imageCount\":0,\"imageList\":null,\"imagePathList\":null,\"imageWidthList\":null,\"imageHeightList\":null,\"commentType\":\"txt\",\"stickerId\":null,\"sticker\":null,\"sortValue\":1508282164602,\"contents\":\"영화찍을때 화재 연기좀 안나게 합시다 매연과 미세먼지 보기만 해도 숨막혀여~\",\"userIdNo\":\"\",\"exposedUserIp\":null,\"lang\":\"ko\",\"country\":\"KR\",\"idType\":\"naver\",\"idProvider\":\"naver\",\"userName\":\"cms2****\",\"userProfileImage\":\"\",\"profileType\":\"naver\",\"modTime\":\"2017-10-18T08:16:04+0900\",\"modTimeGmt\":\"2017-10-17T23:16:04+0000\",\"regTime\":\"2017-10-18T08:16:04+0900\",\"regTimeGmt\":\"2017-10-17T23:16:04+0000\",\"sympathyCount\":0,\"antipathyCount\":0,\"userBlind\":false,\"hideReplyButton\":false,\"status\":0,\"mine\":false,\"best\":false,\"mentions\":null,\"toUser\":null,\"userStatus\":0,\"categoryImage\":null,\"open\":true,\"levelCode\":null,\"grades\":null,\"sympathy\":false,\"antipathy\":false,\"snsList\":null,\"metaInfo\":null,\"extension\":null,\"audioInfoList\":null,\"translation\":null,\"report\":null,\"middleBlindReport\":false,\"spamInfo\":null,\"userHomepageUrl\":null,\"defamation\":false,\"hiddenByCleanbot\":false,\"visible\":true,\"serviceId\":null,\"idNo\":\"\",\"manager\":false,\"deleted\":false,\"blindReport\":false,\"anonymous\":false,\"expose\":true,\"exposeByCountry\":false,\"virtual\":false,\"secret\":false,\"blind\":false,\"profileUserId\":null,\"containText\":true,\"maskedUserId\":\"cms2****\",\"maskedUserName\":\"cm****\",\"validateBanWords\":false},{\"ticket\":\"news\",\"objectId\":\"news437,0000165410\",\"categoryId\":\"*\",\"templateId\":\"default_society\",\"commentNo\":1099240845,\"parentCommentNo\":1099240845,\"replyLevel\":1,\"replyCount\":2,\"replyAllCount\":2,\"replyPreviewNo\":null,\"replyList\":null,\"imageCount\":0,\"imageList\":null,\"imagePathList\":null,\"imageWidthList\":null,\"imageHeightList\":null,\"commentType\":\"txt\",\"stickerId\":\"\",\"sticker\":null,\"sortValue\":1508281805188,\"contents\":\"\",\"userIdNo\":\"\",\"exposedUserIp\":null,\"lang\":\"ko\",\"country\":\"KR\",\"idType\":\"naver\",\"idProvider\":\"naver\",\"userName\":\"drip****\",\"userProfileImage\":\"\",\"profileType\":\"naver\",\"modTime\":\"2017-11-16T19:05:52+0900\",\"modTimeGmt\":\"2017-11-16T10:05:52+0000\",\"regTime\":\"2017-10-18T08:10:05+0900\",\"regTimeGmt\":\"2017-10-17T23:10:05+0000\",\"sympathyCount\":0,\"antipathyCount\":0,\"userBlind\":false,\"hideReplyButton\":false,\"status\":1,\"mine\":false,\"best\":false,\"mentions\":null,\"toUser\":null,\"userStatus\":null,\"categoryImage\":null,\"open\":false,\"levelCode\":null,\"grades\":null,\"sympathy\":false,\"antipathy\":false,\"snsList\":null,\"metaInfo\":null,\"extension\":null,\"audioInfoList\":null,\"translation\":null,\"report\":null,\"middleBlindReport\":false,\"spamInfo\":null,\"userHomepageUrl\":null,\"defamation\":false,\"hiddenByCleanbot\":false,\"visible\":false,\"serviceId\":null,\"idNo\":\"\",\"manager\":false,\"deleted\":true,\"blindReport\":false,\"anonymous\":false,\"expose\":true,\"exposeByCountry\":false,\"virtual\":false,\"secret\":false,\"blind\":false,\"profileUserId\":null,\"containText\":true,\"maskedUserId\":\"drip****\",\"maskedUserName\":\"dr****\",\"validateBanWords\":false},{\"ticket\":\"news\",\"objectId\":\"news437,0000165410\",\"categoryId\":\"*\",\"templateId\":\"view_society\",\"commentNo\":1099239645,\"parentCommentNo\":1099239645,\"replyLevel\":1,\"replyCount\":0,\"replyAllCount\":0,\"replyPreviewNo\":null,\"replyList\":null,\"imageCount\":0,\"imageList\":null,\"imagePathList\":null,\"imageWidthList\":null,\"imageHeightList\":null,\"commentType\":\"txt\",\"stickerId\":null,\"sticker\":null,\"sortValue\":1508281642086,\"contents\":\"헐리웃 영화나 일본 애니메이션처럼 수십년을 사랑 받은 것도 아니고 반짝 드라마 세트장에 안일하게 세금 투입 ㅋㅋㅋ시즌제 드라마라면 이해라도 하지\",\"userIdNo\":\"\",\"exposedUserIp\":null,\"lang\":\"ko\",\"country\":\"KR\",\"idType\":\"naver\",\"idProvider\":\"naver\",\"userName\":\"manm****\",\"userProfileImage\":\"\",\"profileType\":\"naver\",\"modTime\":\"2017-10-18T08:07:22+0900\",\"modTimeGmt\":\"2017-10-17T23:07:22+0000\",\"regTime\":\"2017-10-18T08:07:22+0900\",\"regTimeGmt\":\"2017-10-17T23:07:22+0000\",\"sympathyCount\":1,\"antipathyCount\":0,\"userBlind\":false,\"hideReplyButton\":false,\"status\":0,\"mine\":false,\"best\":false,\"mentions\":null,\"toUser\":null,\"userStatus\":0,\"categoryImage\":null,\"open\":true,\"levelCode\":null,\"grades\":null,\"sympathy\":false,\"antipathy\":false,\"snsList\":null,\"metaInfo\":null,\"extension\":null,\"audioInfoList\":null,\"translation\":null,\"report\":null,\"middleBlindReport\":false,\"spamInfo\":null,\"userHomepageUrl\":null,\"defamation\":false,\"hiddenByCleanbot\":false,\"visible\":true,\"serviceId\":null,\"idNo\":\"\",\"manager\":false,\"deleted\":false,\"blindReport\":false,\"anonymous\":false,\"expose\":true,\"exposeByCountry\":false,\"virtual\":false,\"secret\":false,\"blind\":false,\"profileUserId\":null,\"containText\":true,\"maskedUserId\":\"manm****\",\"maskedUserName\":\"ma****\",\"validateBanWords\":false},{\"ticket\":\"news\",\"objectId\":\"news437,0000165410\",\"categoryId\":\"*\",\"templateId\":\"view_society\",\"commentNo\":1099238685,\"parentCommentNo\":1099238685,\"replyLevel\":1,\"replyCount\":0,\"replyAllCount\":0,\"replyPreviewNo\":null,\"replyList\":null,\"imageCount\":0,\"imageList\":null,\"imagePathList\":null,\"imageWidthList\":null,\"imageHeightList\":null,\"commentType\":\"txt\",\"stickerId\":null,\"sticker\":null,\"sortValue\":1508281518668,\"contents\":\"청주 제빵왕김탁구세트장이랑 영광의 제인 빵집은 지금 어린이집과 유치원 빵만드는 시설과 빵집 국수집 같이하고 있는데... 이런 기사 보면 여기는 참 잘 활용하는 듯.\",\"userIdNo\":\"\",\"exposedUserIp\":null,\"lang\":\"ko\",\"country\":\"KR\",\"idType\":\"naver\",\"idProvider\":\"naver\",\"userName\":\"nyj7****\",\"userProfileImage\":\"\",\"profileType\":\"naver\",\"modTime\":\"2017-10-18T08:05:18+0900\",\"modTimeGmt\":\"2017-10-17T23:05:18+0000\",\"regTime\":\"2017-10-18T08:05:18+0900\",\"regTimeGmt\":\"2017-10-17T23:05:18+0000\",\"sympathyCount\":0,\"antipathyCount\":1,\"userBlind\":false,\"hideReplyButton\":false,\"status\":0,\"mine\":false,\"best\":false,\"mentions\":null,\"toUser\":null,\"userStatus\":0,\"categoryImage\":null,\"open\":false,\"levelCode\":null,\"grades\":null,\"sympathy\":false,\"antipathy\":false,\"snsList\":null,\"metaInfo\":null,\"extension\":null,\"audioInfoList\":null,\"translation\":null,\"report\":null,\"middleBlindReport\":false,\"spamInfo\":null,\"userHomepageUrl\":null,\"defamation\":false,\"hiddenByCleanbot\":false,\"visible\":true,\"serviceId\":null,\"idNo\":\"\",\"manager\":false,\"deleted\":false,\"blindReport\":false,\"anonymous\":false,\"expose\":true,\"exposeByCountry\":false,\"virtual\":false,\"secret\":false,\"blind\":false,\"profileUserId\":null,\"containText\":true,\"maskedUserId\":\"nyj7****\",\"maskedUserName\":\"ny****\",\"validateBanWords\":false}],\"pageModel\":{\"page\":1,\"pageSize\":10,\"indexSize\":10,\"startRow\":1,\"endRow\":10,\"totalRows\":481,\"startIndex\":0,\"totalPages\":49,\"firstPage\":1,\"prevPage\":0,\"nextPage\":2,\"lastPage\":10,\"current\":null,\"threshold\":null,\"moveToLastPage\":false,\"moveToComment\":false,\"moveToLastPrev\":false},\"exposureConfig\":{\"reason\":null,\"status\":\"COMMENT_ON\"},\"count\":{\"comment\":481,\"reply\":86,\"exposeCount\":370,\"delCommentByUser\":122,\"delCommentByMon\":0,\"blindCommentByUser\":0,\"blindReplyByUser\":0,\"total\":567},\"listStatus\":\"all\",\"sort\":\"NEW\",\"bestList\":[]},\"date\":\"2019-08-27T00:34:50+0000\"});" ``` --- ## json 파싱 표준 json의 경우는 httr 패키지의 content() 함수가 자동으로 list 자료형으로 변환해주나 네이버 댓글의 경우 표준과 모양이 달라서 fromJSON() 함수가 에러 발생. ```r url<-"https://apis.naver.com/commentBox/cbox/web_naver_list_jsonp.json?ticket=news&templateId=view_society&pool=cbox5&_callback=jQuery1707377572341505474_1508264183038&lang=ko&country=&objectId=news437%2C0000165410&categoryId=&pageSize=10&indexSize=10&groupId=&listType=OBJECT&page=1&sort=new&includeAllStatus=true&_=1508264264524" ref<-"http://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=102&oid=437&aid=0000165410" con <- httr::GET(url, httr::add_headers(Referer = ref)) tt <- httr::content(con, "text") jsonlite::fromJSON(tt) ``` ```{} Error: lexical error: invalid char in json text. jQuery1707377572341505474_15082 (right here) ------^ ``` --- ```r url<-"https://apis.naver.com/commentBox/cbox/web_naver_list_jsonp.json?ticket=news&templateId=view_society&pool=cbox5&_callback=jQuery1707377572341505474_1508264183038&lang=ko&country=&objectId=news437%2C0000165410&categoryId=&pageSize=10&indexSize=10&groupId=&listType=OBJECT&page=1&sort=new&includeAllStatus=true&_=1508264264524" ref<-"http://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=102&oid=437&aid=0000165410" con <- httr::GET(url, httr::add_headers(Referer = ref)) tt <- httr::content(con, "text") tt <- gsub("(;|\n|_callback|jQuery1707377572341505474_1508264183038)", "", tt) tt <- gsub("\\(", "[", tt) tt <- gsub("\\)", "]", tt) data <- jsonlite::fromJSON(tt) data$result$commentList[[1]]$contents ``` ``` ## [1] "드라마세트장같은건 시간이 지나면 서서히 시들게 되있음 그럼 거기다 돈을 투자할려면 장기적으로 보고 후에 다른 컨텐츠를 확보해서 유지할 생각을 해야되는데 아무도 그런생각을 안함. 그런 상황도 모르고 지차체에서 돈퍼줄 생각을 한 사람도 잘라야됨" ## [2] "" ## [3] "관리와 꾸준한 홍보 했음 이리 허물겠어? 주민들도 그래 지들이 관광객 받을 생각이였음 누워서 떡먹을 생각말고 지들끼리라도 발전시켰어야지" ## [4] "" ## [5] "임기내에 뭔가 보이는 업적 쌓아보겠다고 이것저것 많이 쳐 만드는데 막상 시간지나면 쓸데없어진게 대다수고 그런데서 세금 줄줄 다 새지. 시공업체 뇌물 받아먹기도 안성맞춤" ## [6] "그래서 다스는 누구껀가요?" ## [7] "영화찍을때 화재 연기좀 안나게 합시다 매연과 미세먼지 보기만 해도 숨막혀여~" ## [8] "" ## [9] "헐리웃 영화나 일본 애니메이션처럼 수십년을 사랑 받은 것도 아니고 반짝 드라마 세트장에 안일하게 세금 투입 ㅋㅋㅋ시즌제 드라마라면 이해라도 하지" ## [10] "청주 제빵왕김탁구세트장이랑 영광의 제인 빵집은 지금 어린이집과 유치원 빵만드는 시설과 빵집 국수집 같이하고 있는데... 이런 기사 보면 여기는 참 잘 활용하는 듯." ``` --- class: center, middle, title-slide # .pen-p[끝!] ### <https://mrchypark.github.io/collect-data-with-r> #### [[github]](https://github.com/mrchypark/collect-data-with-r) [[의견 및 오류 신고]](https://github.com/mrchypark/collect-data-with-r/issues/new) [keyring]: https://github.com/r-lib/keyring [pushbullet]: https://www.pushbullet.com/ [clipr]: https://github.com/mdlincoln/clipr [taskscheduleR]: https://github.com/bnosac/taskscheduleR [KeyboardSimulator]: https://github.com/ChiHangChen/KeyboardSimulator [Rpushbullet]: https://github.com/eddelbuettel/rpushbullet [mail]: mailto:mrchypark@gmail.com [fb]: https://www.facebook.com/mrchypark [github]: https://github.com/mrchypark