www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - [std.net.curl] Downloading multiple files using download()

reply "Jack" <Jackoz530 gmail.com> writes:
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 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"
Dec 27 2014
parent reply ketmar via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Sun, 28 Dec 2014 06:14:09 +0000
Jack via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:

 I'm trying to create a sort of "downloader" where it will=20
 download multiple pages of "comics" which are in ".jpg" format.=20
 Now the problem is, that when I used the "download() function":
download(url, location);
Where: url =3D direct link to the image location =3D "/downloads/" ~ to!string(x) ~ ".jpg"; (x is the page=20 number) =20 It would spew out an error code:
 std.stream.OpenException std/stream.d(50): Cannot open or=20
 create file >'/downloads/1.jpg'
=20 I dug around to see that nothing but the documentation page has=20 an example for this, but unfortunately it was only for one file. =20 So can anyone help me? =20 Note: I can't get the url here since the url is a little bit=20 "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! ;-)
Dec 27 2014
parent reply "Jack" <Jackoz530 gmail.com> writes:
On Sunday, 28 December 2014 at 06:26:18 UTC, ketmar via 
Digitalmars-d-learn wrote:
 On Sun, 28 Dec 2014 06:14:09 +0000
 Jack via Digitalmars-d-learn 
 <digitalmars-d-learn 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 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! ;-)
As much as my brotherhood senses push me into revealing the links(they're in json), doing that will reveal my guilty pleasures and fetishes. Well, anywho, thanks for that. I appreciate it.
Dec 27 2014
parent reply ketmar via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Sun, 28 Dec 2014 06:51:14 +0000
Jack via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:

 As much as my brotherhood senses push me into revealing the=20
 links(they're in json), doing that will reveal my guilty=20
 pleasures and fetishes. Well, anywho, thanks for that. I=20
 appreciate it.
ah, 'cmon, nobody knows that you are you here! besides, you can sign as "Jack the Knife", for example. we will never realise that this is your alter-ego!
Dec 27 2014
parent reply "Jack" <Jackoz530 gmail.com> writes:
On Sunday, 28 December 2014 at 06:59:02 UTC, ketmar via 
Digitalmars-d-learn wrote:
 On Sun, 28 Dec 2014 06:51:14 +0000
 Jack via Digitalmars-d-learn 
 <digitalmars-d-learn puremagic.com> wrote:

 As much as my brotherhood senses push me into revealing the 
 links(they're in json), doing that will reveal my guilty 
 pleasures and fetishes. Well, anywho, thanks for that. I 
 appreciate it.
ah, 'cmon, nobody knows that you are you here! besides, you can sign as "Jack the Knife", for example. we will never realise that this is your alter-ego!
Well it's not really that much of a link really. I swear. It's just like fapping to drawings or some sort of thing. Not really THAT good of a comic. *sweats*
Dec 27 2014
parent reply ketmar via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Sun, 28 Dec 2014 07:24:53 +0000
Jack via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:

 Well it's not really that much of a link really. I swear.
 It's just like fapping to drawings or some sort of thing.
 Not really THAT good of a comic. *sweats*
so that's not one of that stories where everyone dies right at the first page? no napalm and burning mechas? ah, nevermind, that was one of my perverted dreams...
Dec 27 2014
parent reply "Jack" <Jackoz530 gmail.com> writes:
On Sunday, 28 December 2014 at 07:33:23 UTC, ketmar via 
Digitalmars-d-learn wrote:
 On Sun, 28 Dec 2014 07:24:53 +0000
 Jack via Digitalmars-d-learn 
 <digitalmars-d-learn puremagic.com> wrote:

 Well it's not really that much of a link really. I swear.
 It's just like fapping to drawings or some sort of thing.
 Not really THAT good of a comic. *sweats*
so that's not one of that stories where everyone dies right at the first page? no napalm and burning mechas? ah, nevermind, that was one of my perverted dreams...
Replace napalm with mayonaise and mechas with octopus "legs". Oh anyway, mind answering one more question? How does one compile for Windows on a Linux Machine using dub? I've been using the "platform" : ["windows"]" configuration in my dub.json to no avail since my Windows installation keeps on screaming out compatibility problems.
Dec 27 2014
parent reply ketmar via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Sun, 28 Dec 2014 07:44:33 +0000
Jack via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:

 How does one compile for Windows on a Linux Machine using dub?=20
 I've been using the "platform" : ["windows"]" configuration in my=20
 dub.json to no avail since my Windows installation keeps on=20
 screaming out compatibility problems.
i don't think that you can do cross-developement with dub now. i believe that the best thing you can do is to run dub.exe and dmd.exe with wine. yet the last time i checked (that was a while ago) dmd.exe with wine was able to produce only segfaults. yet i'm not an expert in both dub and windows, so i don't really know. i think that cross-developmenet question worth a separate topic.
Dec 27 2014
parent "Jack" <Jackoz530 gmail.com> writes:
On Sunday, 28 December 2014 at 07:52:24 UTC, ketmar via 
Digitalmars-d-learn wrote:
 On Sun, 28 Dec 2014 07:44:33 +0000
 Jack via Digitalmars-d-learn 
 <digitalmars-d-learn puremagic.com> wrote:

 How does one compile for Windows on a Linux Machine using dub? 
 I've been using the "platform" : ["windows"]" configuration in 
 my dub.json to no avail since my Windows installation keeps on 
 screaming out compatibility problems.
i don't think that you can do cross-developement with dub now. i believe that the best thing you can do is to run dub.exe and dmd.exe with wine. yet the last time i checked (that was a while ago) dmd.exe with wine was able to produce only segfaults. yet i'm not an expert in both dub and windows, so i don't really know. i think that cross-developmenet question worth a separate topic.
Well that's a shame then. Thanks for the help ketmar.
Dec 28 2014