Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting several files from Web
#7
Macro Macro26
Code:
Copy      Help
;allow single instance
if(getopt(nthreads)>1) end "The thread is already running. You can end it in the 'Running items' pane."
;create folder for files
str folder="$desktop$\test643"
mkdir folder

;list of files to download
str files=
;http://www.eduplace.com/ss/maps/pdf/us_nl.pdf
;http://www.un.org/Depts/dhl/maplib/images_maplib/unflag.gif

;call sub-function Download for each file
str s
int filenum=1
foreach s files
,sub.Download folder s filenum
,filenum+1


#sub Download
function str'folder str'url index
spe -1

str sf sd ;;variables

;download imagefile data into variable sd
int downloaded
rep 60 ;;repeat max 10 minutes every 10 s until success
,IntGetFile url sd
,err 10; continue ;;if error, retry after 10 s
,downloaded=1
,break
if(!downloaded) end F"failed to download {url}"

;format filename and save to file
sf.getfilename(url 1)
str ext.GetFilenameExt(sf)
str timef.timeformat("{yyyy-MM-dd}")
_s.from("File" index "-" timef "." ext)
sd.setfile(F"{folder}\{_s}")


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)