Sure it’s possible, but I don’t get the naming scheme. Today is the 14th, but the script is called 25.pdf. Is it always Monday = 23, Tuesday = 24, Wednesday = 25, etc.?
Think gonna write the newspaper to kindly ask them if they can change the naming into something workable… you never know perhaps they listen… never hapens when you do not ask it or not?
try this, it should work on condition, that the design of the website doesn’t change
It grabs the date of the topmost issue and the corresponding URL from the site , compares it with
the current date and download the pdf, if the dates match.
(I hope, the dutch month names are correct ;))
property destinationfolder : path to desktop as Unicode text
property monthList : {"januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"}
tell (current date) to set {dy, mn, yr} to {day, its month as integer, year}
-- get date of topmost issue
set currentIssue to words 4 thru 6 of (do shell script "curl http://www.depers.nl/uitgaven.php | grep 'Uitgave van'")
-- compare current date with date of current issue
if item 1 of currentIssue as integer = dy and item 2 of currentIssue = item mn of monthList and item 3 of currentIssue as integer = yr then
set theURL to paragraph 1 of (do shell script "curl http://www.depers.nl/uitgaven.php | grep lees | cut -f 2 -d '\"' | cut -f 1 -d '\"'")
set datestring to ((dy as string) & "_" & mn as string) & "_" & yr as string
set destpath to quoted form of POSIX path of (destinationfolder & "DagbladDePers-" & datestring & ".pdf")
do shell script "curl " & theURL & " -o " & destpath
end if
wow stefan many thanks that does the trick! When running the script the newspaper is downloaded perfectly.
one little question more as “brutal” me is
After I Placed the script within Automator and so it places the lastest issue on the desktop, I cannot simply use the “open images in preview”. So have to ad something extra I guess within the script? Do you have a clue?
Thanks
Bob
ps will send you also a e-mail soon with some aditional info/ question
I would just add a line to open the downloaded pdf in preview.app
...
set datestring to ((dy as string) & "_" & mn as string) & "_" & yr as string
set currentIssueFile to destinationfolder & "DagbladDePers-" & datestring & ".pdf"
do shell script "curl " & theURL & " -o " & quoted form of POSIX path of currentIssueFile
tell application "Preview" to open currentIssueFile
end if