Downloading images from a website

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Fermin
Posts: 149
Joined: Fri Jun 05, 2015 10:44 pm

Downloading images from a website

Post by Fermin » Sun Nov 08, 2020 8:03 pm

Is it possible to use LiveCode to download images from the internet to the computer?... I'm using the libURLDownloadToFile command but I can't get it, can someone please help me? Thank you very much.

For example:
https://img.kiosko.net/2020/11/08/es/canarias7.750.jpg
https://img.kiosko.net/2020/11/08/es/sport.750.jpg

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Downloading images from a website

Post by Klaus » Sun Nov 08, 2020 8:36 pm

Hola Fermin,

hm, this worked for me:

Code: Select all

on mouseUp 
   put specialfolderpath("desktop") & "/el_testo666.jpg" into tFile
   libURLDownloadToFile "https://img.kiosko.net/2020/11/08/es/canarias7.750.jpg",tFile
end mouseUp
What did you script so far?


Best

Klaus

Fermin
Posts: 149
Joined: Fri Jun 05, 2015 10:44 pm

Re: Downloading images from a website

Post by Fermin » Sun Nov 08, 2020 9:01 pm

Hi, Klaus. I'm back in Livecode (since a long time) and yesterday I started to prepare a utility to download newspaper covers. I've hardly used LiveCode with the Internet and until today I didn't know the libURLDownloadToFile command. I had been trying it for a while and wasn't sure if it would work, so I asked for help .... And like other times before, you gave me a hand. Thanks a lot, Klaus.
I put a little bit of my code (testing it crazy) but I already imagine that I was doing it wrong. The code you sent me works well so I'm going to investigate it and adapt it to my work. Thanks again. :D

Translated with www.DeepL.com/Translator (free version)

on mouseUp
/*201007-1753*/
put "http://kiosko.net" into cabe
put "np" into nipu
put ".html" into final
put "http://kiosko.net/es/2020-09-30/np/elcorreo.html" into cosa
put "http://kiosko.net/es/np/elcorreo.html" into foto
put "/Users/miMac27d/Downloads" into casa

put "https://img.kiosko.net/2020/11/08/es/la ... ia.750.jpg" into imagen

launch url imagen

-- load url cosa as timage
--+++ launch url "http://kiosko.net/es/2020-09-30/np/elcorreo.html"
---
libURLDownloadToFile imagen, casa,"downloadComplete"
-- answer the result
---
exit to top

launch url "http://kiosko.net/es/2020-09-30/np/elcorreo.html"
launch url "http://kiosko.net/es/2020-11-07/np/elcorreo.html"
launch url "http://kiosko.net/es/2020-11-08/np/elcorreo.html"
launch url "http://kiosko.net/es/np/elcorreo.html"
end mouseUp
Last edited by Fermin on Sun Nov 08, 2020 9:31 pm, edited 2 times in total.

Fermin
Posts: 149
Joined: Fri Jun 05, 2015 10:44 pm

Re: Downloading images from a website

Post by Fermin » Sun Nov 08, 2020 9:22 pm

Of course, there was the destination folder... but the file name (laDeskarga.jpg) was missing!
put "/Users/miMac27d/Downloads/laDeskarga.jpg" into casa

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Downloading images from a website

Post by Klaus » Sun Nov 08, 2020 11:30 pm

Exactamento! :-)

Post Reply