title: Download png/jpg with R
body: <p>i would like to download all of images from <a href="http://thedevilsguard.tumblr.com/page/1" rel="noreferrer">this site</a> but after downloading photos all are corrupted. What i should do to download them successfully?</p>
  
  <p>My code:</p>
  
  <pre><code>library(XML)
  dir.create('c:/photos')
  urls&lt;-paste("http://thedevilsguard.tumblr.com/page/",1:1870,sep="")
  doc&lt;-htmlParse(urls[1])
  links&lt;-unique(unlist(xpathApply(doc,'//div[@class="timestamp"]/a',xmlGetAttr,'href')))
  for (i in 1:length(links)){
    doc2&lt;-htmlParse(links[i])
    link&lt;-xpathApply(doc2,'//div[@class="centre photopage"]//p//img',xmlGetAttr,'src')[[1]][1]
    download.file(link,paste("C:/photos/",basename(link),""))
  }
  </code></pre>