File 在applescript中,如何返回web上文件的内容?
在applescript中,如何返回web上文件的内容?因此,如果我使用foo.com/untitle.txt,它会给我该文件的内容。我建议使用File 在applescript中,如何返回web上文件的内容?,file,applescript,File,Applescript,在applescript中,如何返回web上文件的内容?因此,如果我使用foo.com/untitle.txt,它会给我该文件的内容。我建议使用do shell script调用命令行实用程序curl来完成该工作,如下所示: set theText to do shell script "/usr/bin/curl http://foo.com/test.txt" 或者另一种方式: on temporaryFile() tell me to POSIX file (do shell s
do shell script
调用命令行实用程序curl
来完成该工作,如下所示:
set theText to do shell script "/usr/bin/curl http://foo.com/test.txt"
或者另一种方式:
on temporaryFile()
tell me to POSIX file (do shell script "/usr/bin/mktemp " & quoted form of (POSIX path of (path to temporary items from user domain) & (do shell script "/usr/bin/basename " & quoted form of POSIX path of (path to me) & " '.app'") & "XXXXXXXX")) as alias
end temporaryFile
on fetchPage(URI)
set temporaryFile0 to my temporaryFile()
tell application "URL Access Scripting"
--progress,form data,directory listing,download directory,authentication
download URI to temporaryFile0 replacing yes
end tell
set fileReference to open for access temporaryFile0
try
set returnValue to read fileReference
on error number -39
set returnValue to ""
end try
close access fileReference
tell application "Finder" to delete temporaryFile0
returnValue
end fetchPage
在curl(URI)上执行shell脚本“/usr/bin/curl”&引用URI end curl的形式
on temporaryFile()
tell me to POSIX file (do shell script "/usr/bin/mktemp " & quoted form of (POSIX path of (path to temporary items from user domain) & (do shell script "/usr/bin/basename " & quoted form of POSIX path of (path to me) & " '.app'") & "XXXXXXXX")) as alias
end temporaryFile
on fetchPage(URI)
set temporaryFile0 to my temporaryFile()
tell application "URL Access Scripting"
--progress,form data,directory listing,download directory,authentication
download URI to temporaryFile0 replacing yes
end tell
set fileReference to open for access temporaryFile0
try
set returnValue to read fileReference
on error number -39
set returnValue to ""
end try
close access fileReference
tell application "Finder" to delete temporaryFile0
returnValue
end fetchPage