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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀