• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Downloading a file from the internet with a URL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Downloading a file from the internet with a URL


  • Subject: Re: Downloading a file from the internet with a URL
  • From: Yvan KOENIG <email@hidden>
  • Date: Thu, 12 May 2016 18:51:23 +0200

Here is a subset of a script which I use quite often.

# Define the path to the storage folder
set destFolder to (path to downloads folder as text) # edit to fit your needs
# Builds the URL
quoted form of ("http://support.apple.com/kb/HT1582?viewlocale=fr_FR")
set XMLbrut to do shell script "curl -Ls -A 'Opera/9.70 (Linux ppc64 ; U; en) Presto/2.2.1' " & result

tell (current date) to set fileName to (((its year) * 10000 + (its month) * 100 + (its day)) as text) & "_" & text 2 thru -1 of ((1000000 + (its hours) * 10000 + (its minutes) * 100 + (its seconds)) as text) & ".txt"
my writeto(destFolder & fileName, XMLbrut, «class utf8», false)

#=====
(*
Handler borrowed from Regulus6633 - http://macscripter.net/viewtopic.php?id=36861
*)
on writeto(targetFile, theData, dataType, apendData)
# targetFile is the path to the file you want to write
# theData is the data you want in the file.
# dataType is the data type of theData and it can be text, list, record etc.
# apendData is true to append theData to the end of the current contents of the file or false to overwrite it
try
set targetFile to targetFile as text
set openFile to open for access file targetFile with write permission
if not apendData then set eof of openFile to 0
write theData to openFile starting at eof as dataType
close access openFile
return true
on error
try
close access file targetFile
end try
return false
end try
end writeto

#=====



Yvan KOENIG running El Capitan 10.11.4 in French (VALLAURIS, France) jeudi 12 mai 2016 18:51:18



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Downloading a file from the internet with a URL
      • From: "Stockly, Ed" <email@hidden>
References: 
 >Re: Downloading a file from the internet with a URL (From: Steve Mills <email@hidden>)
 >Re: Downloading a file from the internet with a URL (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: Downloading a file from the internet with a URL
  • Next by Date: Re: Downloading a file from the internet with a URL
  • Previous by thread: Re: Downloading a file from the internet with a URL
  • Next by thread: Re: Downloading a file from the internet with a URL
  • Index(es):
    • Date
    • Thread