LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Download files from the internet

I wish to download files from the internet programatically. I can download an HTML source file very easily, but how do I download a JPG or ZIP file for example? Accessing these files must be more complicated because one can start part way through such files (useful if they're large and the link breaks during transmission) and the size can be known before the file transfer is complete. Is it easy to give passwords too � in either case?

I�ve attached a couple of examples. The first, �Download http source.vi� downloads the 26kB very simply and crudely. The second, �Download picture.vi� won�t get anything from Data socket read.

What I need is a really simple vi which will download a simple file. Anything further, like cop
ing with part-way re-starts, passwords, and knowing when the transfer is complete would be a very welcome bonus.

Can anyone help, please?
Download All
0 Kudos
Message 1 of 6
(4,576 Views)
R-

You can always download a win32 compiled version of wget and use the external command function to call that. Wget is a very common way to download files and it's quite robust. You just call wget with the url and destination path as the arguments (uh, i think. 😄 ). With the "External Command" vi you should also be able to set "Wait Until Finished" to false to be able to run several download threads simultaneously.

I've used this, and it worked for me.

Micah
0 Kudos
Message 2 of 6
(4,576 Views)
Micah,

Thanks for your reply. "wget" is completely new to me and superficially looking though a few pages from Google, looks to be far more difficult to use than I would expect. Perhaps I lack the knowledge to do this task! All I wanted was a simple vi like "DataSocket Read.vi" which I could use to download a file. If I must use �wget�, could you point me to where I can best learn about it, please? And possibly where best to download compiled code (for Win XP)? Does this come as some sort of driver or library? I have some knowledge of LabVIEW, but really don�t know much about how the internet actually works (which is probably very obvious).

I can't help thinking someone else has solved this and that a crude solution must be (almost?) as simple as my first file
attached to my previous post.

If I'm told this is a real challenge for some reason then I will accept that and struggle to reach a solution alone. I would however appreciate a big nudge in the right direction.

Richard.
0 Kudos
Message 3 of 6
(4,576 Views)
If all you want is to download a file (any file), and save to disk, no edit before save, then you can use "File Download" at:

http://www.geocities.com/gzou999/gtool.html


George Zou
http://gtoolbox.yeah.net
George Zou
0 Kudos
Message 4 of 6
(4,576 Views)
I think the most satisfying answer for you is to append the string "[text]" to the end of the URL you input to the DataSocket Read VI. This forces DataSocket to treat the target file as an arbitrary chunk of bytes and avoid any special processing or formatting.

Also, interpret the variant Data output as a string instead of an array. Save that string to file and voila, you have your JPG or whatever else you're trying to download.

Find more on this topic by searching the NI support site for "datasocket ftp text" or similar.

One caution: DataSocket really isn't the same as HTTP or FTP; it's a (currently) proprietary protocol that NI will continue to evolve over time. The "[text]" trick isn't (to my knowledge) strongly documented, so it would be a mistake t
o assume that it will always work with future releases of LabVIEW or DataSocket. It works now, though, and it's extremely simple.

Regards,
John Lum
National Instruments
Message 5 of 6
(4,576 Views)
John,

Thanks, this is just the push in the right direction that I needed. I've tried it. It's simple and works. It gives me the opportunity to get something up and running immediately.

I know there's plenty more for me to learn in this area but at least I'm moving now.

Working file attached if anyone's interested.

Thanks again, Richard.
0 Kudos
Message 6 of 6
(4,575 Views)