AppleScript; interaction with web ?

Posted:
in Mac Software edited January 2014
I want to write an AppleScript which downloads a image and displays it in a window.

I just don't want to go and open the browser for that.



Is something like that possible with AppleScript ?



<a href="http://www.alpinejetservice.ch/image/alpinecam.jpg"; target="_blank">url of the image I want to use</a> (Sion in Switzerland)





Comments

  • Reply 1 of 8
    xaqtlyxaqtly Posts: 450member
    Yes it's possible, but my Applescripting skills are novice at best and I probably couldn't script it. But there are a lot of people who are really good at it that could do it.
  • Reply 2 of 8
    defiantdefiant Posts: 4,876member
    thanks for your reply, Xactly.



    Could you point me to "those" people who know how to do that ?
  • Reply 3 of 8
    carlcarl Posts: 17member
    [quote]Originally posted by Defiant:

    <strong>thanks for your reply, Xactly.



    Could you point me to "those" people who know how to do that ?</strong><hr></blockquote>



    Here is a start at the script which will open it in the Quicktime window for you. It does not refresh it automatically yet. Here is the script which you can cut and paste into the script editor application under OS 9 or 10. Hope this helps ..



    tell application "QuickTime Player"

    \tactivate

    \topen location {"http://www.alpinejetservice.ch/image/alpinecam.jpg";}

    end tell :cool:
  • Reply 4 of 8
    carlcarl Posts: 17member
    [quote]Originally posted by Defiant:

    <strong>thanks for your reply, Xactly.



    Could you point me to "those" people who know how to do that ?</strong><hr></blockquote>

    Here is another one you can cut and paste into the script editor. It is based on the Apple example script delivered with OS X. It will open the URL and grab the image and open in the Preview app on your desktop. Were you looking to have this app automatically update the image on some interval?



    set picture_name to "alpinecam.jpg"

    set the target_URL to "http://www.alpinejetservice.ch/image/"; & picture_name

    set the destination_file to ((path to desktop as string) & "picture.jpg")

    tell application "URL Access Scripting"

    \tdownload target_URL to file destination_file replacing yes

    end tell



    tell application "Finder" to open alias destination_file
  • Reply 5 of 8
    carlcarl Posts: 17member
    [quote]Originally posted by Defiant:

    <strong>thanks for your reply, Xactly.



    Could you point me to "those" people who know how to do that ?</strong><hr></blockquote>

    One last mod for you.. this one will open the image in Preview. If you keep it running and close the image in Preview, it will refresh the image and reopen it.



    set picture_name to "alpinecam.jpg"

    set the target_URL to "http://www.alpinejetservice.ch/image/"; & picture_name

    set the destination_file to ((path to desktop as string) & "picture.jpg")

    repeat

    \ttell application "URL Access Scripting"

    \t\tdownload target_URL to file destination_file replacing yes

    \tend tell

    \tdelay 5

    \ttell application "Finder" to open alias destination_file

    \tdelay 5

    end repeat
  • Reply 6 of 8
    defiantdefiant Posts: 4,876member
    hey Carl, thanks for your help, it looks like you're a script-master. that's good.



    the first script ran fine. nice.



    but, I compiled the second and the third one of your two scripts; they download the image to my desktop, but then they both give me an error: "Finder got an error: Can't get alias "path/to/the/file/on/my/desktop/picture.jpg"



    why is that ? do I need an extension ?



    Yes, I was looking to have this app update every minute.



    Thank you very much for your help, carl.



    [ 12-28-2002: Message edited by: Defiant ]</p>
  • Reply 7 of 8
    [quote]Originally posted by Defiant:

    <strong>hey Carl, thanks for your help, it looks like you're a script-master. that's good.



    the first script ran fine. nice.



    but, I compiled the second and the third one of your two scripts; they download the image to my desktop, but then they both give me an error: "Finder got an error: Can't get alias "path/to/the/file/on/my/desktop/picture.jpg"



    why is that ? do I need an extension ?



    Yes, I was looking to have this app update every minute.



    Thank you very much for your help, carl.



    [ 12-28-2002: Message edited by: Defiant ]</strong><hr></blockquote>

    Humm, glad the first worked. Are you running OS X or 9? I actually ran the second one on two different machines here last night and it worked on both. I was looking at the refresh thing too.. I will post the refresh version if I can figure it out. I actually had never written a script before, but have always wanted to learn Applescript and your challenge is an interesting test case. Will post the new version as soon as I can defeat the refresh bit. Thanks Carl
  • Reply 8 of 8
    defiantdefiant Posts: 4,876member
    I am running OS 10.2.3



    btw, e-mail me if you want to know more, this is more complicated and part of a bigger project.



    try this one: (comes with the example scripts and does also not work...)



    [code] set weather_map to "acttemp_720x486.jpg" -- temperatures

    set weather_map to "curwx_720x486.jpg" -- surface isobars



    set the target_URL to "http://maps.weather.com/images/maps/current/"; & weather_map

    set the destination_file to ((path to desktop as string) & "weathermap.jpg")



    tell application "URL Access Scripting"

    \tdownload target_URL to file destination_file replacing yes

    end tell



    tell application "Finder" to open alias destination_file </pre><hr></blockquote>
Sign In or Register to comment.