Git Product home page Git Product logo

Comments (5)

mrchypark avatar mrchypark commented on May 30, 2024

안녕하세요, 그럴경우 read_html(url, encoding="UTF-8")으로 해보시면 좋을것 같습니다. 감사합니다.

from n2h4.

xvyaward avatar xvyaward commented on May 30, 2024

아직 해결을 못했습니다ㅠ
다른게 문제가 아니고 제 추측으로는
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.

xvyaward avatar xvyaward commented on May 30, 2024

해결했습니다.

Encoding(res$content) <- "UTF-8"

이 코드를 삽입하니 바로 되는군요

from n2h4.

mrchypark avatar mrchypark commented on May 30, 2024

@xvyaward 오 감사합니다. #res$content<-iconv(rawToChar(res$content),to="UTF-8") 아마 이것이 OS에 따라 동작이 다른듯 해서 주석처리 해서 그런것 같습니다. 좋은 정보 공유해주셔서 감사합니다.

from n2h4.

xvyaward avatar xvyaward commented on May 30, 2024

혹시 가능하다면 스포츠 뉴스에서 댓글추출에 도움을 요청해도될까요..?

스포츠 뉴스 중 하나에서 크롬 개발자모드 -> 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=newsticket=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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.