[std.net.curl] Downloading multiple files using download()

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 27 22:26:04 PST 2014


On Sun, 28 Dec 2014 06:14:09 +0000
Jack via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com> wrote:

> I'm trying to create a sort of "downloader" where it will 
> download multiple pages of "comics" which are in ".jpg" format. 
> Now the problem is, that when I used the "download() function":
> >download(url, location);
> Where:
> url = direct link to the image
> location = "/downloads/" ~ to!string(x) ~ ".jpg"; (x is the page 
> number)
> 
> It would spew out an error code:
> > std.stream.OpenException at std/stream.d(50): Cannot open or 
> > create file >'/downloads/1.jpg'
> 
> I dug around to see that nothing but the documentation page has 
> an example for this, but unfortunately it was only for one file.
> 
> So can anyone help me?
> 
> Note: I can't get the url here since the url is a little bit 
> "NSFW"
you are trying to write the file to "/download" directory, that
obviously doesn't exist.

`url` arg is the FULL url -- the one that you'll pass to wget to
download the picture. and `location` is the DISK location of the
resulting file (i.e. the file that will be created). as you are passing
the absolute path for it, it starts searching from the root directory.

now remove that pesky '/' at the start of the `location` and give us
the link, as NSFW comics are specially good at sundays! ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141228/13ad9805/attachment-0001.sig>


More information about the Digitalmars-d-learn mailing list