logo

[r-crawling] 뉴스, 게시판 등 글 목록에서 글의 URL만 뽑아내기

library(httr)
library(rvest)

기사 목록 가져오기

res = GET('http://news.naver.com/main/list.nhn?mode=LSD&mid=sec&sid1=001&listType=summary&date=20150609')

기사 링크 추출

htxt = html(res)
link = html_nodes(htxt, 'div.list_body a')

링크에서 기사 주소를 나타내는 어트리뷰트 href만 뽑아내고 중복을 제거

article.href = unique(html_attr(link, 'href'))
Previous
실습: 쿠키를 이용한 온오프믹스 로그인