logo

[r-crawling] JavaScript 사례 분석: 인벤 댓글 크롤링

library(httr)
library(rvest)

POST 방식으로 댓글을 가져옵니다

comment.url = 'http://www.inven.co.kr/common/board/comment.xml.php?dummy=1433931866095'
comment = POST(comment.url,
               body=list(
                 comeidx=2152,
                 articlecode=19094,
                 sortorder='date',
                 act='list',
                 out='xml',
                 replynick='',
                 replyidx=0))

XML 형식으로 해석합니다

x = xml(comment)

item 노드 밑에 있는 o_comment 노드를 찾아서 텍스트를 추출합니다

xml_text(xml_nodes(x, 'item o_comment'))
repair_encoding(xml_text(xml_nodes(x, 'item o_comment')))  ##  윈도의 경우
Previous
날짜 처리