Download png/jpg with R

前端 未结 2 2107
半阙折子戏
半阙折子戏 2020-12-14 23:18

i would like to download all of images from this site but after downloading photos all are corrupted. What i should do to download them successfully?

My code:

<
相关标签:
2条回答
  • 2020-12-14 23:20

    So it looks you are under Windows. When you download binary files, you have to specify the mode to be binary, e.g.

    download.file(link, ..., mode = 'wb')
    

    see ?download.file for details.

    0 讨论(0)
  • 2020-12-14 23:27

    First, try and download one. Do this:

    link = "http://29.media.tumblr.com/tumblr_m0q2g8mhGK1qk6uvyo1_500.png"
    download.file(link,basename(link))
    

    Does that work?

    I notice its a PNG and NOT a JPEG, so maybe you are trying to read it in as a JPEG.

    0 讨论(0)
提交回复
热议问题