IPB

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topic
> ASS - Récupérer la météo d'une ville, [AppleScript Studio]
Options
Nono95400
posté 5 Apr 2007, 18:05
Message #1


Macbidouilleur d'argent !
***

Groupe : Membres
Messages : 710
Inscrit : 16 Oct 2004
Membre no 25 318



Bonsoir,

J'aimerais récupérer ajouter dans mon application en ASS une fonction de récupération de la météo d'une ville (choisie par l'utilisateur dans une liste).
Le résultat devra être de préférence sous la forme de : 18°
Ou bien : 18° soleil


Je n'ai pas de souci pour faire la liste de choix de villes.

Mes 2 principaux soucis sont :

- Trouver sur le net ses informations (la météo en France et si possible d'autres pays)
- Récupérer ses informations (commande shell curl ou bien webView)


Merci smile.gif


EDIT :

J'ai trouvé un webservice pour la météo : http://www.severalways.org/WS/BerreWeather/BerreWeather.php

Mais je ne comprend pas du tout comment ça fonctionne !!! NEED HELPPPPPP

Ce message a été modifié par Nono95400 - 5 Apr 2007, 18:45.


--------------------
MacBook Pro 13" M1 2020 - 16Go de RAM - SSD 256Go
Mac Pro early '09 Quad-Core Intel Xeon 2,93 GHz - 8Go de RAM - ATI HD5870 1Go - SSD Vortex 2 128Go - HD 1To, 2To, 3To.
MacBook Air 13" i7 1,8Ghz - 4Go de RAM - SSD 256Go
Go to the top of the page
 
+Quote Post
Old Salt
posté 6 Apr 2007, 08:04
Message #2


Macbidouilleur d'Or !
*****

Groupe : Membres
Messages : 2 255
Inscrit : 31 Mar 2003
Lieu : 17000 La Rochelle
Membre no 6 906



Pour les données météo, je te conseille de faire une recherche Google avec le mot METAR et le nom de la ville voulue. METAR concerne les stations météo des aéroports.
Certains sites proposent un choix d'aéroports, d'autres sont dédiés à un seul...
Une fois sur le site choisi, dans Safari, tu utilises le menu Présentation / Code source...
Il te faut alors repérer dans le code les données qui t'intéressent et créer ton programme pour les isoler et supprimer tout le reste (en particulier avec les instructions sur les chaînes de caractères).
smile.gif
Il y a probablement d'autres méthodes, mais c'est ainsi que je procède pour récupérer des données internet...


--------------------
iMac 27" (modèle mai 2011) / Lion

MacUser depuis 1985 (Macintosh 128)
Go to the top of the page
 
+Quote Post
Nono95400
posté 6 Apr 2007, 13:08
Message #3


Macbidouilleur d'argent !
***

Groupe : Membres
Messages : 710
Inscrit : 16 Oct 2004
Membre no 25 318



Euh ce n'est pas tout à fait ce que je souhaite.


Voici le code AS pour récupérer la météo avec un webservice (USA uniquement) :
CODE
(*
WSDL URL:    http://www.xmethods.net/sd/2001/TemperatureService.wsdl  
(IBM WSDL Toolkit 1.1 - compatible version)
*)

-- SET THE DEFAULT VALUES
property SOAP_Endpoint_URL : "http://services.xmethods.net:80/soap/servlet"
property SOAP_app : "rpcrouter"
property method_name : "getTemp"
property method_namespace_URI : "urn:xmethods-Temperature"
property SOAP_action : ""

-- QUERY USER FOR THE ZIPCODE
set this_text to "95014"
repeat
    try
        display dialog "Check Temperature by Zipcode" & return & return & ¬
            "Enter the 5-digit zipcode to check:" default answer this_text
        set this_text to the text returned of the result
        if this_text is not "" and ¬
            the length of this_text is 5 and ¬
            (this_text as number) is greater than 0 and ¬
            (this_text as number) is less than 100000 then
            set this_zipcode to this_text as string
            exit repeat
        else
            error
        end if
    on error number error_number
        if the error_number is -128 then error number -128
        beep
    end try
end repeat

-- CREATE THE PARAMETER RECORD
set the method_parameters to {zipcode:this_text}

-- CALL THE SOAP SUB-ROUTINE
copy my SOAP_call(SOAP_Endpoint_URL, SOAP_app, method_name, method_namespace_URI, method_parameters, SOAP_action) to {call_indicator, call_result}
if the call_indicator is false then
    beep
    display dialog "An error occurred." & return & return & call_result buttons {"Cancel"} default button 1
else
    -- CONVERT THE RESPONSE TO FAHRENHEIT AND CELSIUS
    set this_temp to the call_result as number
    if this_temp is -999 then
        display dialog "No temperature information is available for zipcode " & this_zipcode & "." buttons {"OK"} default button 1
    else
        set temp_F to this_temp as degrees Fahrenheit
        set temp_C to (round ((temp_F as degrees Celsius) as number)) as string
        set temp_F to (round (temp_F as number)) as string
        display dialog "The current temperature in zipcode " & this_zipcode & " is: " & ¬
            return & return & ¬
            temp_F & "º Fahrenheit" & return & temp_C & "º Celsius" buttons {"OK"} default button 1
    end if
end if

on SOAP_call(SOAP_Endpoint_URL, SOAP_app, method_name, method_namespace_URI, method_parameters, SOAP_action)
    try
        using terms from application "http://www.apple.com/placebo"
            tell application SOAP_app of machine SOAP_Endpoint_URL
                set this_result to call soap ¬
                    {method name:method_name ¬
                        , method namespace uri:method_namespace_URI ¬
                        , parameters:method_parameters ¬
                        , SOAPAction:SOAP_action}
            end tell
        end using terms from
        return {true, this_result}
    on error error_message number error_number
        if the error_number is -916 then ¬
            set the error_message to "The script was unable to establish a connection to the Internet."
        return {false, error_message}
    end try
end SOAP_call


C'est ce code que je souhaiterais adapter pour ce webservice :

"Name: GetWeather
Binding: BerreWeatherBinding
Endpoint: http://www.severalways.org/WS/BerreWeather/BerreWeather.php
SoapAction: urn:BerreWeather#GetWeather
Style: rpc
Input:
use: encoded
namespace: urn:BerreWeather
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: GetWeatherRequest
parts:
City: xsd:string
Output:
use: encoded
namespace: urn:BerreWeather
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: GetWeatherResponse
parts:
Weather: tns:WeatherReport
Namespace: urn:BerreWeather
Transport: http://schemas.xmlsoap.org/soap/http
Documentation: Get weather report for major cities around the Etang de Berre. Currently, only 'Marignane' and 'Istres' cities are supported. For testing purposes, new cities have been added to BerreWeather DataBase.Thank you for your comprehension. NB.: Use http://www.mindreef.net in order to test this WebService."


--------------------
MacBook Pro 13" M1 2020 - 16Go de RAM - SSD 256Go
Mac Pro early '09 Quad-Core Intel Xeon 2,93 GHz - 8Go de RAM - ATI HD5870 1Go - SSD Vortex 2 128Go - HD 1To, 2To, 3To.
MacBook Air 13" i7 1,8Ghz - 4Go de RAM - SSD 256Go
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



Nous sommes le : 4th April 2026 - 15:51