Comments (5)
안녕하세요, 그럴경우 read_html(url, encoding="UTF-8")으로 해보시면 좋을것 같습니다. 감사합니다.
from n2h4.
아직 해결을 못했습니다ㅠ
다른게 문제가 아니고 제 추측으로는
success <- function(res){
cat("Request done! Status:", res$status, "\n")
#res$content<-iconv(rawToChar(res$content),to="UTF-8")
res$content<-rawToChar(res$content)
data <<- c(data, list(res))
}
이 과정을 거치면서 문제가 발생하는 것 같은데,
[1] 3c 21 44 4f 43 54 59 50 45 20 68 74 6d 6c 3e 0a 3c 68 74 6d 6c 20 6c 61 6e 67 3d 22 6b 6f 22 3e 0a 3c 68 65 61 64 3e 0a 09 3c 6d 65 74 61 20 63 68 61 72 73 65 74 3d 22 55 54 46 2d 38
[62] 22 3e 0a 09 3c 6d 65 74 61 20 68 74 74 70 2d 65 71 75 69 76 3d 22 58 2d 55 41 2d 43 6f 6d 70 61 74 69 62 6c 65 22 20 63 6f 6e 74 65 6e 74 3d 22 49 45 3d 65 64 67 65 22 3e 0a 09 3c 6d
이런 raw byte들이 변환된 후의 data를 csv파일로 저장해서 열어보면 한글만 다 깨져있었습니다. 그래서 뒤의 data를 이용하는 함수들 역시 인코딩 문제가 발생한 것 같습니다.
전체 코드를 해석해봤지만 data frame이 정확히 어떻게 구성되는지 아직 이해하는중이라, 저 부분은 잘모르겠네요.. rawTochar에서 인코딩문제를 해결할 방법이 있을까요?
아 참고로 중간에 주석처리 된 부분을 살려서 돌려봤는데,
Error: 'NA' does not exist in current working directory 의 오류가 발생하네요
from n2h4.
해결했습니다.
Encoding(res$content) <- "UTF-8"
이 코드를 삽입하니 바로 되는군요
from n2h4.
@xvyaward 오 감사합니다. #res$content<-iconv(rawToChar(res$content),to="UTF-8") 아마 이것이 OS에 따라 동작이 다른듯 해서 주석처리 해서 그런것 같습니다. 좋은 정보 공유해주셔서 감사합니다.
from n2h4.
혹시 가능하다면 스포츠 뉴스에서 댓글추출에 도움을 요청해도될까요..?
스포츠 뉴스 중 하나에서 크롬 개발자모드 -> network를 확인해보니 댓글수집 api가
http://apis.naver.com/commentBox/cbox/web_naver_list_jsonp.json?ticket=sports&templateId=view&pool=cbox2&_callback=jQuery1113020049989799848422_1509795433279&lang=ko&country=KR&objectId=news025%2C0002750844&categoryId=&pageSize=20&indexSize=10&groupId=&listType=OBJECT&page=1&initialize=true&userType=&useAltSort=true&replyPageSize=20&moveTo=&sort=LIKE&_=1509795433280
이런식으로 되어있더군요
그래서 getComment의
url <- paste0("https://apis.naver.com/commentBox/cbox/web_naver_list_jsonp.json?ticket=news&templateId=view_politics&pool=cbox5&lang=ko&country=KR&objectId=news", oid, "%2C", aid, "&categoryId=&pageSize=", pageSize, "&indexSize=10&groupId=&page=", page, "&initialize=true&useAltSort=true&replyPageSize=30&moveTo=&sort=", sort)
에서
ticket=news
를 ticket=sports
로,
templateId=view_politics
--> templateId=view
sort=LIKE
로 주고
url <- paste0("https://apis.naver.com/commentBox/cbox/web_naver_list_jsonp.json?ticket=sports&templateId=view&pool=cbox2&lang=ko&country=KR&objectId=news", oid, "%2C", aid, "&categoryId=&pageSize=", pageSize, "&indexSize=10&groupId=&listType=OBJECT&page=", page, "&initialize=true&userType=&useAltSort=true&replyPageSize=20&moveTo=&sort=LIKE")
이렇게 바꿔서 해봤는데 잘 안되네요.. api 건드리는 건 힘들다고 듣긴했는데 혹시 조언을 얻을 수 있을까요?
from n2h4.
Related Issues (20)
- 한글 문서 적용 HOT 1
- logo HOT 1
- pkgdown 테마 변경
- 댓글 사용자의 지난 댓글 데이터 가져오기
- url 조합을 urltools 사용으로 변경 HOT 2
- 리드미 업데이트 HOT 1
- url 체크를 인터넷 콜 사용하는 부분 개선 HOT 1
- 함수명 스타일 변경
- 기사 원문 링크를 제공하면 좋겠습니다.
- 기자의 이름도 가져오면 좋겠습니다.
- getAll 함수를 제거하고 pageSize 에서 "all"을 받으면 좋겠습니다.
- wiki 를 article 로 옮깁니다.
- 깃헙 액션의 탬플릿 버전을 v2로 변경합니다. HOT 1
- 수집된 뉴스 댓글 중복 문제 HOT 9
- test covr 를 올립니다. HOT 1
- pkgdown 함수 설명 페이지에 카테고리 구분을 추가합니다.
- cache를 환경 변수로 제어합니다.
- 기존 함수에 경고 메세지 추가 HOT 1
- 레거시 버전 설치 방법 지원 HOT 1
- cache 폴더를 cran에서 문제 제기 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from n2h4.