1

URL を 1 行ずつ読み取って Safari で開く AppleScript があります。これです:

set thePath to (path to desktop as Unicode text) & "sites.txt"
set theFile to (open for access file thePath)
set theContent to (read theFile)
close access theFile

set theURLs to every paragraph of theContent

tell application "Safari"
    repeat with theURL in theURLs
        make new document
        set URL of front document to theURL
        delay 1
        repeat until ((do JavaScript "document.readyState" in front document) is "complete")
            delay 30
        end repeat
        close front document
    end repeat
end tell

この例では、これらの URL を使用しています。これらの URL は、共有できない私のユース ケースと非常によく似ています。

http://www.omdbapi.com/?t=True%20Grit&y=1969

http://www.omdbapi.com/?t=アバター&y=2009

この AppleScript は私にとっては問題なく動作しますが、リクエストごとにコンテンツをデスクトップの txt ファイルに書き戻すことはできません。

誰でも助けることができますか?

4

1 に答える 1

0

試す:

set thePath to (path to desktop as text) & "sites.txt"
set outPath to quoted form of (POSIX path of (path to desktop as text) & "sites content.txt")

set theUrls to every paragraph of (read file thePath)

set myContent to {}
repeat with aURL in theUrls
    set end of myContent to aURL & return
    set pageContent to do shell script "curl " & aURL
    set end of myContent to pageContent & return & return
end repeat

do shell script "echo " & quoted form of (myContent as text) & " >> " & outPath
于 2012-11-26T18:33:39.727 に答える