Link to home
Start Free TrialLog in
Avatar of formadmirer
formadmirerFlag for United States of America

asked on

VFP 9 Download Images Via URL

Hello Experts.

I have a few thousand product images I need to download. Each is referenced by a url in the format: hxxp://foo.bar/product_number.jpg

The site however contains tens of thousands of images. I need a fraction of them.
Instead of downloading each individually, which would take me weeks, I was wondering if I could accomplish this with fp.
The individual filenames (product numbers appended with .jpg) are already contained in a vfp table.

Can I scan or loop through this table and have vfp retrieve each image for me, and if so, how?
Thx!
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

If you are able to access the web via FTP then you may loop through your table and generate a script to download all pictures by some FTP client (e.g. FTP.EXE in DOS mode).

You could also use some freeware, e.g.
http://www.chami.com/tips/windows/062598W.html
http://www.vicman.net/getfree/WebGrab_38662s.html
ASKER CERTIFIED SOLUTION
Avatar of JF0
JF0
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of formadmirer

ASKER

Thanks for the replies.

I may be missing something, but each method above appears to rely on me manually entering each image url to be downloaded.

What I really need is a way to use the already existing images names in the table to initiate the downloads.

I can have vfp access a website url using DECLARE INTEGER ShellExecute/FindWindow, what I need is a way after accessing the url to have fp download the image that resides at the url.

JFO -

I just looked over what you suggested again and on second look it looks like this is exactly what I need.

I haven't tested anything yet, but just wanted to say thanks in advance.
I created a .prg but when I compile I get:

Program c:\stuff\download_images.prg has the following errors:
    Unknown HTTPGET - Undefined

I included the line
SET LIBRARY TO (LOCFILE("vfpconnection.fll","FLL"))
and the vfpconnection.fll file does exist in a subdirectory of the program.

What am I missing/doing wrong??

DECLARE LONG URLDownloadToFile IN URLMON.DLL LONG, STRING, STRING, LONG, LONG
nResult = URLDownloadToFile(0, cURL, cFileName, 0, 0)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Finally got it sorted out and it worked absolutely beautifully. Thank you!

CaptainCyril - I'm not sure what DECLARE LONG... does as I've never used it before, but the .prg wound up working without it.

As for your second suggestion, that is what I was looking for in the beginning and sounds ideal.

I'll run it both ways with a limited data set and see which works best. Thanks for the suggestion.

DECLARE registers an API Function in Windows so you can call it from VFP.
DECLARE LONG URLDownloadToFile IN URLMON.DLL LONG, STRING, STRING, LONG, LONG
cURL = "http://www.mywebsite.com/mypicture.jpg"
cFileName = "c:\pics\mypicture.jpg"
nResult = URLDownloadToFile(0, cURL, cFileName, 0, 0)