donglingsai2880 2015-06-17 18:38
浏览 56
已采纳

如何从XML文件下载图像?

I'm rebuilding a website for fun (but also making it better) and I want to batch download the images that are on the site. I have found an XML file which contains all the links to the images (or at least some of them). Here's the file.

Is there a way to download all the images in this XML with a Windows program or a script of some sort? Thank you very much.

  • 写回答

1条回答 默认 最新

  • douluhaikao93943 2015-06-17 19:13
    关注

    You need to do three things:

    1. Extract/create the urls from the xml file
      • Use a text editor's find & replace (sublime texts ctrl-shift-g is especially great)
    2. Use an http client to download one url
    3. Expand this method to loop over all the urls:
      • Trivial if you used DownloadThemAll, see this stack overflow if you use a batch file, or consider using powerhsell.

    Additionally, you could install other programming languages such as python or ruby, and use an http library that they have. The setup is longer, but the syntax is likely easier once setup in such languages.

    Update: If you use search and replace on the xml document to create an html page containing a list of links like so:

    <body>  
      <a href="http://gkvrozenburg-voorne.nl/images/45.jpg" download>link</a>
      <a href="http://gkvrozenburg-voorne.nl/images/IMG_3026.jpg" download>link</a>
      <a href="http://gkvrozenburg-voorne.nl/images/IMG_3037.jpg" download>link</a>
      <a href="http://gkvrozenburg-voorne.nl/images/IMG_3039.jpg" download>link</a>
      <a href="http://gkvrozenburg-voorne.nl/images/IMG_3047.jpg" download>link</a>
    </body>
    

    Then you can open it up in a browser, start the browsers javascript console and type the following:

    var anchors = document.getElementsByTagName('a')
    for (var i = 0; i < anchors.length; i++) {
      anchors[i].click()
    }
    

    This will download all of the images.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作