Hallo zusammen,
ich bin neu hier und auch recht neu mit AppleScript unterwegs, habe auch im Forum gesucht bin aber leider nicht fündig geworden.
Ich würde gerne ein PDF von einer Webseite speichern. Da ich mich auf diese Webseite einloggen muss und ein Cookie gesetzt wird etc. funktioniert das Abspeichern mit "URL Access Scripting" nicht. Zumindest ist das meine Theorie
Gibt es eine Funktion/Objekt mit Safari mit dem ich das machen kann und wie muss der Pfad aussehen...
So mache ich es bis jetzt und es funktioniert alles, bis auf das abspeichern.
Wäre euch für eine Hilfe sehr dankbar.
ich bin neu hier und auch recht neu mit AppleScript unterwegs, habe auch im Forum gesucht bin aber leider nicht fündig geworden.
Ich würde gerne ein PDF von einer Webseite speichern. Da ich mich auf diese Webseite einloggen muss und ein Cookie gesetzt wird etc. funktioniert das Abspeichern mit "URL Access Scripting" nicht. Zumindest ist das meine Theorie
Gibt es eine Funktion/Objekt mit Safari mit dem ich das machen kann und wie muss der Pfad aussehen...
So mache ich es bis jetzt und es funktioniert alles, bis auf das abspeichern.
Code:
set mainURL to "<Webseite>" as text
set mainLogin to "<User>" as text
set mainPword to "<PWD>" as text
tell application "Safari"
activate
set thisDocument to make new document at end of documents
-- open MainWindow
do JavaScript "window.open('" & mainURL & "')" in thisDocument
tell application "System Events"
-- login
tell application process "Safari"
delay 5
-- keystroke (ASCII character 9) — tab character
keystroke (ASCII character 9) -- tab character
keystroke mainLogin
--delay 1
keystroke (ASCII character 9) -- tab character
--delay 1
keystroke mainPword
keystroke (ASCII character 13) -- this equals return
delay 5
end tell
end tell
-- open stupid iFrames
set sDownloadseite to do JavaScript "parent.ErstesiFrame.Zweitesiframe.document.links[0].href" in front document
do JavaScript "window.open('" & sDownloadseite & "')" in front document
delay 3
-- get PDF Url
set sPdfUrl to do JavaScript "document.links[0].href" in front document
delay 3
-- get PDF Name
set AppleScript's text item delimiters to "/"
set sFileName to last text item of (sPdfUrl as text)
set AppleScript's text item delimiters to ""
--- save PDF
tell application "URL Access Scripting"
download sPdfUrl to "/Users/username/" & sFileName replacing yes
end tell
end tell