rothwild
Goto Top

Apple-Script öffnet URL und schreibt Ergebnis in ein TXT zurück

AppleScript vs. Batch-File

Liebe Admins,

ich habe eine Liste mit rund 15.000 URL in einer TXT Datei, die eine API ansprechen sollen. Ich habe also derzeit ein File das URls beinhaltet, wie etwa (Ich habe inzwischen mal einen ähnlichen Service gefunden, wie den, den ich benutzen muss.)

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

Das Ergebnis der Website ist dann ein geparster Inhalt aus einer Datenbank.

Was ich nicht hinbekomme ist, ein Apple-Script zum Laufen zu bringen, das nun Folgendes können soll.

• erste URL = erste Zeile nehmen (aus File urls.txt)
• der URL "folgen"
• den Inhalt des Request zurückschreiben (2.File (urls-ready.txt))
• 30 Sekunden pausieren
• zur nächsten URL marschieren = nächste Zeile

Bitte helfen … :/ AppleScript vs. Batch-File heißt: ich sitze an einem Mac und mir wäre nicht bekannt, dass ich hier ein Bach-File anschmeißen kann.

UPDATE:

Bislang habe ich dieses hier:

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

Aber auf diese Weise öffnet er nur alle URLs in Safari, ich schaffe es nicht, den Content der Website zurück zu schreiben.

Content-Key: 194923

Url: https://administrator.de/contentid/194923

Printed on: April 20, 2024 at 03:04 o'clock

Member: Rothwild
Rothwild Nov 26, 2012 at 20:23:00 (UTC)
Goto Top
Ich habe es gelöst. Danke für die 'Hilfe'.


set thePath to (path to desktop as Unicode text) & "sites.txt"
set theFile to (open for access file thePath)
set theResult to (path to desktop as Unicode text) & "movieresults.txt"
set theFileResult to (open for access theResult with write permission)
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 2
repeat until ((do JavaScript "document.readyState" in front document) is "complete")
delay 2
end repeat
set resulter to get text of tab 1 of window 1
write resulter to theFileResult
close front document
end repeat
end tell

close access theFileResult

Falls jemand noch Verbesserungen hat, würde ich mich freuen …