javascript - How to fetch image from Website url and store all images in folder in PC? - Stack Overflow

Hello I want to fetch all images from this url on the website and store it on my D drive like d: H

Hello I want to fetch all images from this url on the website / and store it on my D drive like d://

How should i do this?

I tried something like following i searched here But it doesnt work ,Please help me out.

<html>
<script src=".11.0/jquery.min.js"></script>
<script>
var dir = "/";
var fileextension = ".jpg";
$.ajax({

    //This will retrieve the contents of the folder if the folder is configured as 'browsable'
    url: dir,
    success: function (data) {
        //Lsit all png file names in the page
        $(data).find("a:contains(" + fileextension + ")").each(function () {
            var filename = this.href.replace(window.location.host, "").replace("http:///", "");
            $("body").append($("<img src=" + dir + filename + "></img>"));
        });
    }
});
</script>
<body>
</body>
</html> 

Hello I want to fetch all images from this url on the website http://www.thesmokingtire./wp-content/uploads/ and store it on my D drive like d://

How should i do this?

I tried something like following i searched here But it doesnt work ,Please help me out.

<html>
<script src="http://ajax.googleapis./ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
var dir = "http://www.thesmokingtire./wp-content/uploads/";
var fileextension = ".jpg";
$.ajax({

    //This will retrieve the contents of the folder if the folder is configured as 'browsable'
    url: dir,
    success: function (data) {
        //Lsit all png file names in the page
        $(data).find("a:contains(" + fileextension + ")").each(function () {
            var filename = this.href.replace(window.location.host, "").replace("http:///", "");
            $("body").append($("<img src=" + dir + filename + "></img>"));
        });
    }
});
</script>
<body>
</body>
</html> 
Share Improve this question asked Apr 12, 2014 at 12:49 0____________00____________0 331 silver badge6 bronze badges 1
  • 3 It would be much more easier to use wget. Take a look (assuming that you are using Windows): gnuwin32.sourceforge/packages/wget.htm Command you are looking for: wget -r --no-parent http://www.thesmokingtire./wp-content/uploads/ – user2824854 Commented Apr 12, 2014 at 12:54
Add a ment  | 

1 Answer 1

Reset to default 6

Yes as already suggested in ments section.

For downloading the images from a site url.We don't have to use ajax requests always.

In this case wget mand should be helpful.

wget -r http://sample.url.
  • Wget is a free network utility to retrieve files from the World Wide Web using HTTP and FTP, the two most widely used Internet protocols. It works non-interactively, thus enabling work in the background, after having logged off.

  • The recursive retrieval of HTML pages, as well as FTP sites is supported -- you can use Wget to make mirrors of archives and home pages, or traverse the web like a WWW robot (Wget understands /robots.txt).

  • Wget works exceedingly well on slow or unstable connections, keeping getting the document until it is fully retrieved. Re-getting files from where it left off works on servers (both HTTP and FTP) that support it. Matching of wildcards and recursive mirroring of directories are available when retrieving via FTP. Both HTTP and FTP retrievals can be time-stamped, thus Wget can see if the remote file has changed since last retrieval and automatically retrieve the new version if it has.

  • Wget supports proxy servers, which can lighten the network load, speed up retrieval and provide access behind firewalls. If you are behind a firewall that requires the use of a socks style gateway, you can get the socks library and pile wget with support for socks.

  • Most of the features are configurable, either through mand-line options, or via initialization file .wgetrc. Wget allows you to install a global startup file (etc/wgetrc by default) for site settings.

Documentation of wget mand.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745652493a4638347.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信