Twice a week I download the list of recently modified technotes.
To do that I use this old fashioned script.
--[SCRIPT]
on run
local listeDescripteurs, rapport
set listeDescripteurs to {}
tell application "Safari"
try
close every document
end try
end tell # Safari
set end of listeDescripteurs to my lisUnePage()
repeat with i from 2 to 4
my ouvrePageSuivante()
if not result then exit repeat
set end of listeDescripteurs to my lisUnePage()
end repeat
try
tell application "Safari" to close every document
end try
set rapport to (path to desktop as text) & "Recently modified.txt"
set listeDescripteurs to my recolle(listeDescripteurs, return)
--set listeDescripteurs to my remplace(listeDescripteurs, tab, return)
set the clipboard to listeDescripteurs
my writeTo(rapport, listeDescripteurs, «class utf8», false)
end run
--=====
on ouvrePageSuivante()
local UrlAvant, disponible
tell application "Safari"
activate
set UrlAvant to URL of document 1
end tell # Safari
tell application "System Events" to tell application process "Safari"
tell (first window whose subrole is "AXStandardWindow") to tell group 3 of first UI element of scroll area 1 of group 1 of group 1 of group -1
try
click (first UI element whose (role is "AXLink" and name is "Next"))
set disponible to true
on error
set disponible to false
end try
end tell # (first window…
end tell # System Events…
if disponible then
tell application "Safari"
repeat until not (URL of document 1) is UrlAvant
delay 0.5
end repeat
end tell
end if
return disponible
end ouvrePageSuivante
--=====
on lisUnePage()
local texteAvant, le_texte, liste_Descripteurs, premier, indx, uneLigne
tell application "Safari"
set texteAvant to "beurk"
repeat 20 times
try
set texteAvant to text of document 1
end try
if texteAvant is not in {"", "beurk"} then exit repeat
tell current application to delay 0.5
end repeat
repeat
delay 0.5
set le_texte to text of document 1
if le_texte = texteAvant then exit repeat
set texteAvant to le_texte
end repeat
end tell # Safari
set liste_Descripteurs to paragraphs of le_texte
set premier to 1
repeat with indx from 1 to count liste_Descripteurs
set uneLigne to (item indx of liste_Descripteurs) as «class utf8»
if uneLigne = "Article Title Article Type Last Modified" then
set premier to (indx + 1)
exit repeat
end if
end repeat
repeat with indx from 1 to count liste_Descripteurs
set uneLigne to (item -indx of liste_Descripteurs) as «class utf8»
if uneLigne = "Previous | Next" then
set liste_Descripteurs to items premier thru -(indx + 1) of liste_Descripteurs
exit repeat
end if
end repeat
return liste_Descripteurs
end lisUnePage
--=====
on recolle(l, d)
local oTIDs, t
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set t to "" & l
set AppleScript's text item delimiters to oTIDs
return t
end recolle
--=====
(*
replaces every occurences of d1 by d2 in the text t
*)
on remplace(t, d1, d2)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d1
set l to text items of t
set AppleScript's text item delimiters to d2
set t to "" & l
set AppleScript's text item delimiters to oTIDs
return t
end remplace
--=====
(*
*)
on writeTo(targetFile, theData, dataType, apendData)
-- targetFile is the path to the file you want to write
-- theData is the data you want in the file.
-- dataType is the data type of theData and it can be text, list, record etc.
-- apendData is true to append theData to the end of the current contents of the file or false to overwrite it
try
set targetFile to targetFile as text
set openFile to open for access file targetFile with write permission
if not apendData then set eof of openFile to 0
write theData to openFile starting at eof as dataType
close access openFile
return true
on error
try
close access file targetFile
end try
return false
end try
end writeTo
--=====
--[/SCRIPT]