그림 가져오기(예제)

library(rvest)
library(httr)

getwd()
## [1] "C:/Users/ACAD/AppData/Local/Temp/RtmpCeQeN2"
setwd("F:\\temp\\")

for(i in 1:573)
{
  page.view <- paste('http://sports.donga.com/Cartoon?cid=0100000204&sid=', i ,sep='')
  res <- html(page.view)
  imgs <- html_nodes(res, 'div.cartoon_view img')
  img.src <- html_attr(imgs, 'src')
  cartoon <- GET(img.src)
  writeBin(content(cartoon, 'raw'), sprintf('%04d.jpg', i))  
}

DOT 나중에 더 도전해 볼 것

res <- GET(‘http://webtoon.daum.net/webtoon/view/damageovertime#7’) htxt <- html(res) imgs <- html_nodes(htxt, ‘div.wrap_list_toon’) imgs

imgs <- html_nodes(htxt, ‘div.tabContentWrap’) imgs

?html_nodes

img.src <- html_attr(imgs, ‘src’) cartoon <- GET(img.src) writeBin(content(cartoon, ‘raw’), sprintf(‘%04d.jpg’, i))

res <- html(‘http://m.webtoon.daum.net/m/webtoon/view/damageovertime#page_no=6’) html_nodes(res, ‘ul’)

imgs