How to download |
Author: |
Message: |
ArkaneArkade
Full Member
The One and Only
Posts: 193 Reputation: 5
39 / /
Joined: Mar 2007
|
O.P. How to download
Hey all,
Working on a little extra, to automatically download an image from a site. Probelm is, one of the images inst a png.
- OK, not very good at explaining - the image specifically is http://www.bungie.net/Stats/halo2emblem.ashx?s=70...=26&bi=36&fl=1&m=1
Because its an ashx page (presumably) the downloadfile doesn't seem to work, Is there a possible method to do it, or is it just impossible?
|
|
11-20-2008 11:05 PM |
|
|
SmokingCookie
Senior Member
Posts: 815 Reputation: 15
30 / /
Joined: Jul 2007
|
RE: How to download
Apparently, downloading from dynamic pages is not possible.
You'll have to save the file manually, host it somewhere else and download it from there.
|
|
11-24-2008 07:31 AM |
|
|
ArkaneArkade
Full Member
The One and Only
Posts: 193 Reputation: 5
39 / /
Joined: Mar 2007
|
O.P. RE: How to download
OK, cheers Smokie. I'll have to figure something else out for that later on. May find some other way to steal the image.
|
|
11-24-2008 08:42 AM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: How to download
The mimetype is image/jpg.
You can use the Win32 API URLDownloadToFile.
Your code would look something like this:
code: function URLDownloadToFile (sUrl, sFile) {
Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', sUrl);
Interop.Call('urlmon.dll', 'URLDownloadToFileW', 0, sUrl, sFile, 0, Interop.GetInterfacePtr('OnProgress'));
}
function OnProgress (ulProgress, ulProgressMax, ulStatusCode, szStatusText) {
if (ulProgress == ulProgressMax) Debug.Trace('Download Complete');
}
Now I cannot guarantee that the callback function for this works because Plus! had to handwrite all of the function callbacks and he may have missed this one. If this is the case then you can do this:
code: function URLDownloadToFile (sUrl, sFile) {
Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', sUrl);
Interop.Call('urlmon.dll', 'URLDownloadToFileW', 0, sUrl, sFile, 0, 0);
}
This post was edited on 11-24-2008 at 01:59 PM by matty.
|
|
11-24-2008 01:55 PM |
|
|
ArkaneArkade
Full Member
The One and Only
Posts: 193 Reputation: 5
39 / /
Joined: Mar 2007
|
O.P. RE: How to download
Cheers matty. I have that working... at least for the download. I get object doesnt support method errors, so I guess that the callback was missed. Shouldn't matter though... I'll just need to figure out some other way to detect it, so that I don't set my image to an incomplete file.
cheers dude
|
|
11-25-2008 05:25 AM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: How to download
quote: Originally posted by Leroux
I'll just need to figure out some other way to detect it, so that I don't set my image to an incomplete file.
Is it possible to compare file sizes?
or md5 hashes if you really wanna go nuts
<Eljay> "Problems encountered: shit blew up"
|
|
11-25-2008 11:58 AM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: How to download
URLDownloadToFile I do believe is a synchronous call meaning when it returns 0 for success the file is done.
|
|
11-25-2008 12:35 PM |
|
|
Matti
Elite Member
Script Developer and Helper
Posts: 1646 Reputation: 39
32 / /
Joined: Apr 2004
|
RE: How to download
quote: Originally posted by matty
URLDownloadToFile I do believe is a synchronous call meaning when it returns 0 for success the file is done.
Unfortunately, it's not.
quote: Returns one of the following values.
S_OK - The download started successfully.
That means: it returns as soon as its started, from there you're supposed to monitor the progress through the callback function - which we can't do unfortunately.
Ugh, how I hate the lack of asynchronous callback support.
|
|
11-25-2008 05:46 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: How to download
quote: Originally posted by Matti
quote: Originally posted by matty
URLDownloadToFile I do believe is a synchronous call meaning when it returns 0 for success the file is done.
Unfortunately, it's not.
That means: it returns as soon as its started, from there you're supposed to monitor the progress through the callback function - which we can't do unfortunately.
Ugh, how I hate the lack of asynchronous callback support.
Oops I didn't actually read the MSDN article ahaha!
And why didn't MsgPlus.DownloadFile work? It should process the url like any other.
This post was edited on 11-25-2008 at 06:17 PM by matty.
|
|
11-25-2008 06:05 PM |
|
|
|