• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: puzzling Safari
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: puzzling Safari


  • Subject: Re: puzzling Safari
  • From: Emmanuel LEVY <email@hidden>
  • Date: Fri, 27 Dec 2013 12:39:29 +0100

Fair enough Yvan :-)

Joyeux Noël à vous !
Happy Xmas to you guys!

Emmanuel

On Dec 27, 2013, at 9:42 AM, koenig.yvan wrote:

>
> Le 26/12/2013 à 12:10, Shane Stanley <email@hidden> a écrit :
>
>> On 26 Dec 2013, at 9:41 PM, koenig.yvan <email@hidden> wrote:
>>
>>> Am I missing something ?
>>
>> Have you tried getting the source of document 1 and saving that using the write command?
>>
>> --
>> Shane Stanley <email@hidden>
>
> Hello Shane
>
> You made half point.
>
> When the asker got your answer he said : OK, it works but it doesn't.
> In fact we discovered  that he was trying to save the contents of a page containing only a picture.
>
> The GUI Scripting scheme
>
> #[SCRIPT]
> activate application "Safari"
> tell application "System Events" to tell process "Safari" to tell window 1
> 	keystroke "s" using command down # Save As…
> 	repeat
> 		delay 0.1
> 		if exists sheet 1 then exit repeat
> 	end repeat
> 	keystroke "d" using command down # save to Desktop
> 	keystroke return
> end tell
> #[/SCRIPT]
>
> was treating every cases but he refused it so I grabbed a curl instruction borrowed from a Nigel Garvey's script and wrote :
>
> #[SCRIPT]
> # quelques instructions pour ouvrir la page de test
> tell application "Safari"
> 	activate
> 	tell document 1
> 		# Defines the URL for tests
> 		set its URL to "http://images.midilibre.fr/images/2013/12/26/des-habitants-de-pissevin-attendent-le-retour-de_766882_510x255.jpg";
> 		delay 5
> 	end tell
> end tell
>
>
> # Le véritable code
> # set destFolder to path to desktop folder as text
> set destFolder to path to documents folder as text
> tell application "Safari"
> 	activate
> 	tell document 1
> 		# comme vous voyez je suis ceinture et bretelles et je généralise l'emploi du préfixe its
> 		set theURL to its URL
> 		set theName to its name
> 	end tell
> end tell
> # supprimons les éventuels : et / qui sont mal vus dans les noms de fichiers
> set theName to my remplace(theName, ":/", "_") & ".jpg"
> # construit le chemin du fichier à créer
> set theFilePath to destFolder & theName
> # il ne serait peut-être pas judicieux d'écraser un fichier homonyme
> tell application "System Events" to set existe to exists disk item theFilePath
> if not existe then
> 	set posixFilePath to quoted form of POSIX path of theFilePath
> 	do shell script "curl -L --user-agent 'Opera/9.70 (Linux ppc64 ; U; en) Presto/2.2.1' --url " & theURL & " -o " & posixFilePath
> 	tell application "Finder"
> 		reveal alias theFilePath
> 		# activate
> 	end tell
> else
> 	error "Le fichier « " & theFilePath & " » existe déjà !"
> end if
>
> #=====
> (*
> replaces every occurences of d1 by d2 in the text t
> *)
> on remplace(t, d1, d2)
> 	local oTIDs, l
> 	set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, 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
>
> #=====
> #[/SCRIPT]
>
> Emmanuel, the well known Smile Guy gave an other answer requiring Smile :
>
> writetext (readtext "http://images.midilibre.fr/images/2013/12/26/des-habitants-de-pissevin-attendent-le-retour-de_766882_510x255.jpg";) encoding "MACINTOSH" to "~/Desktop/paysage.jpg"
>
> For "standard" web page he gave :
> set laPage to readtext "http://www.quomodo.com";
> writetext laPage to "~/Desktop/test-smile.html"
>
> Yvan KOENIG (VALLAURIS, France) vendredi 27 décembre 2013 09:42:03
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


References: 
 >puzzling Safari (From: "koenig.yvan" <email@hidden>)
 >Re: puzzling Safari (From: Shane Stanley <email@hidden>)
 >Re: puzzling Safari (From: "koenig.yvan" <email@hidden>)

  • Prev by Date: Re: puzzling Safari
  • Next by Date: puzzled by grep
  • Previous by thread: Re: puzzling Safari
  • Next by thread: puzzled by grep
  • Index(es):
    • Date
    • Thread