IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Delphi Discussion :

Téléchargement sur une page Web


Sujet :

Delphi

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut Téléchargement sur une page Web
    Bonjour,

    Je souhaiterais pouvoir, à partir de mon application télécharger des données sur une page Web.
    Pour cela je dois fournir à cette page certaines informations issues de mon application.

    Pourriez vous me dire comment pratiquer?

    Voici le code de la page Web en question:
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>Navlost.eu - METAR and TAF Archive</title>
    <link rel="stylesheet" type="text/css" href="/css/style-1col.css" />
     
    </head>
    <body>
    <div id="header">
    <h1>Navlost.eu</h1>
    <h2><!---Navigation &amp; --->Positioning Resources</h2>
     <div id="menu">
      <ul id="nav">
       <li><a href="/" accesskey="H">Home</a></li>
       <li><a href="/nwxs/doc/desc"  >NWX</a></li>
       <li><a href="/aero/met"  >Weather</a></li>
       <li><a href="/weather/marine"  >Maritime Forecast</a></li>
       <li><a href="/aero/fpl"  >VFR Flight Planner</a></li>
       <li><a href="/survey/gpsd/"  >qtGPSc</a></li>
       <li><a href="/contact">Contact</a></li>
      </ul>
     </div>
    </div>
     
    <div id="content"><div id="right">
    <!--- Main content Starts Here --->
    <h2>METAR and TAF Archive</h2>
     
    <p><form id="aero.metar.search" action="http://navlost.eu/aero/metar/" method="get">
    <table>
      <tr><th>ICAO</th><td><input type="text" name="icao" value="" title="ICAO identifier(s) to retrieve"/>
            <span style="font-size:8pt;color:darkgray;"><i>E.g.:</i> LFMD <i>(separate multiple identifiers with spaces)</i></span></td></tr>
      <tr><th>Date</th><td><input type="text" name="dt0" value="" title="Date and time of the LATEST report to return. Leave blank for the most recent"/>
            <span style="font-size:8pt;color:darkgray;"><i>E.g.:</i> 15:00 21 Nov <i>or</i> 2008-11-21 15:00 <i>or</i> now <i>(optional)</i></span></td></tr>
      <tr><th>Count</th><td><select name="c" title="Number of reports to return"><option value="1">1</option>
    <option value="5">5</option>
    <option value="10">10</option>
    <option value="20">20</option>
    <option value="30">30</option>
    <option value="40">40</option>
    <option value="50">50</option>
    <option value="100">100</option>
    </select>
     <span style="font-size:8pt;color:darkgray;"><i>Number of reports to retrieve for each identifier</i></span></td></tr>
      <tr><th>Type</th><td><select name="rt" title="Report type"><option value="metar">METAR</option><option value="taf">TAF</option></select></td></tr>
      <tr><th></th><td><input type="submit" value="Search" accesskey="S" title="Accesskey: 'S'"/></td></tr>
    </table>
    </form>
    </p>
    <script>
      el = document.getElementById('aero.metar.search');
      el.elements[0].focus();
    </script>
     
    <p style="font-weight:bold;">Retrieve METAR and TAF information <a href="email" title="METAR and TAF By Email">via email</a>.</p>
     
    <p>The earliest records in this archive date from 2008-11-06 12:00 UTC</p>
    <p style="font-style:italic;"><b>Please note:</b> Due to a modification of the
    underlying database engine, reports older than about two weeks at times might
    be unreachable.  In that case, you may use the <a href="/contact">contact
    form</a> to drop me an email with the details of your query and I'll be happy
    to retrieve the requested data from offline storage and mail it back to you.</p>
    <p style="font-style:italic;"><b>Thinking of using a <a href="http://foldoc.org/bot">bot</a>?</b> Don't. You will get blocked. Use the <a href="/nwxs/doc/desc">NWX Service <abbr title="Application Program Interface">API</abbrv></a> instead.</p>
     
    <!--- Main content Ends Here --->
    </div><div id="googleads.bottom"><script type="text/javascript"><!--
    google_ad_client = "pub-0968849576395715";
    /* 728x15, created 9/17/08 */
    google_ad_slot = "9180212476";
    google_ad_width = 728;
    google_ad_height = 15;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </div></div>
    <div id="footer">
    <p>Copyright &copy; 2014 <a href="/contact">Diego Berge</a><br/>
    Hosting by <a href="http://www.gandi.net/">Gandi.net</a></p>
    </div>
     
    </body>
    </html>

    L'application doit fournir le code ICAO, la date et heure les autres champs restent sans modification.
    Elle doit récupérer le texte se trouvant sous la ligne horizontale.

    Je joins également une screen de la page avec le texte à récupérer en bas (EDDK 110550Z 34006KT 6000 FEW005 BKN007 BKN012 17/16 Q1013 TEMPO 4000 BR BKN004)

    Nom : Capture.JPG
Affichages : 150
Taille : 39,3 Ko

    Merci de votre aide précieuse.

    Cordialement
    Pierre

  2. #2
    Membre expérimenté
    Avatar de ouiouioui
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Août 2006
    Messages
    984
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Août 2006
    Messages : 984
    Points : 1 419
    Points
    1 419
    Par défaut
    Bonjour,

    vous avez remarqué la ligne :
    Thinking of using a bot? Don't. You will get blocked. Use the NWX Service API instead.
    Donc le mieux serait d'utiliser sa http://navlost.eu/nwxs/doc/

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut
    Merci de cette réponse.

    En fait jusqu'ici, je téléchargeais les METAR de cette façon sur un autre site.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
     
    // Récupération données meteo sur internet
        Ts                               := TStringList.Create;
        try
          Ts.Add('cccc='+ ICAO);
          IdHttp1.Request.ContentType    := 'application/x-www-form-urlencoded';
          if BtnLoad.Tag = 1  then
          begin
            MemMETARa.lines.Append  (IdHTTP1.Post
                                  ('http://weather.noaa.gov/mgetmetar.php',Ts));
            MemMETARa.Color              := clWhite;
          end
          else
          begin
            MemMETAR.lines.Append  (IdHTTP1.Post
                                  ('http://weather.noaa.gov/mgetmetar.php',Ts));
            MemMETAR.Color               := clWhite;
          end;
            ParseResult;
        finally
          Ts.free;
        end;
    Je ne comprends pas comment utiliser les requêtes du site malgré leurs explications avec mon composant IdHTTP.
    Je dois entrer le code ICAO de l'aéroport concerné et la date/heure souhaitée.

    Pourriez vous m'aider?

    Cordialement
    Pierre

  4. #4
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut
    Bonjour,
    Je me permet de vous donner quelques précisions.
    Voici le code de la page sur laquelle je souhaite récupérer la chaine (gras en rouge) après avoir utilisé mon navigateur pour générer la requête.
    Les paramètres de cette requête(en gras bleu)
    Peut-être pourrez vous m'aider grâce à cela :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    <p><form id="aero.metar.search" action="http://navlost.eu/aero/metar/" method="get">
    <table>
      <tr><th>ICAO</th><td><input type="text" name="icao" value="EDDK" title="ICAO identifier(s) to retrieve"/>
            <span style="font-size:8pt;color:darkgray;"><i>E.g.:</i> LFMD <i>(separate multiple identifiers with spaces)</i></span></td></tr>
      <tr><th>Date</th><td><input type="text" name="dt0" value="2014-06-15 12:00:00" title="Date and time of the LATEST report to return. Leave blank for the most recent"/>
            <span style="font-size:8pt;color:darkgray;"><i>E.g.:</i> 15:00 21 Nov <i>or</i> 2008-11-21 15:00 <i>or</i> now <i>(optional)</i></span></td></tr>
      <tr><th>Count</th><td><select name="c" title="Number of reports to return"><option value="1"selected>1</option>
    <option value="5">5</option>
    <option value="10">10</option>
    <option value="20">20</option>
    <option value="30">30</option>
    <option value="40">40</option>
    <option value="50">50</option>
    <option value="100">100</option>
    </select>
     <span style="font-size:8pt;color:darkgray;"><i>Number of reports to retrieve for each identifier</i></span></td></tr>
      <tr><th>Type</th><td><select name="rt" title="Report type"><option value="metar">METAR</option><option value="taf">TAF</option></select></td></tr>
      <tr><th></th><td><input type="submit" value="Search" accesskey="S" title="Accesskey: 'S'"/></td></tr>
    </table>
    </form>
    </p>
    <script>
      el = document.getElementById('aero.metar.search');
      el.elements[0].focus();
    </script>
    
    <p><a href="http://navlost.eu/aero/metar/">New Search</a></p>
    <p><hr/><br/><code>EDDK 151150Z 36008KT 9999 SCT045 20/09 Q1022 NOSIG</code><br/><br/>
    </p>
    Merci de vos conseils.

    Cordialement
    Pierre

  5. #5
    Membre éclairé
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    707
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 707
    Points : 777
    Points
    777
    Par défaut
    Pour analyser les requêtes, je te conseille d'utiliser un outil comme Fiddler, ça te permettra de voir exactement comment ça se passe avec ton navigateur et de vérifier que les requêtes de ton programme sont identiques.

  6. #6
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut
    Merci beaucoup, cela me donne déjà une piste à explorer...

    Bien cordialement
    Pierre

  7. #7
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut
    Bonjour,

    J'ai installé Fiddler et tenté d'écrire une requête.
    Nom : Capture.JPG
Affichages : 138
Taille : 143,9 Ko
    J'obtiens bien le bon résultat dans Fiddler, mais pas dans mon application avec le code suivant:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
     MemMETAR.lines.Append  (IdHTTP1.get
                                  ('http://navlost.eu/aero/metar/'
                                  + '?icao=EDDK'
                                  + '&dt0=2014-06-15 12:00')
                                  + '&c=1'
                                  + '&rt=1');
    Merci de votre aide

    Cordialement
    Pierre

  8. #8
    Membre éclairé
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    707
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 707
    Points : 777
    Points
    777
    Par défaut
    Quel est le résultat dans ton application ? En général une page web retourne un code d'erreur qui peut te mettre sur la voie...
    Si tu analyses la requête de ton programme dans Fiddler, est-elle bien identique ?

    PS: probablement un problème d'encodage (espace dans la date et heure)...

  9. #9
    Membre habitué
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    439
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 439
    Points : 161
    Points
    161
    Par défaut
    Bonjour et merci pour réponse Dominicale.

    En effet je viens de corriger la chaîne de la requête et j'obtiens bien le code de la page avec le résultat souhaité.
    Il ne me reste plus qu'à extraire la partie de code du message METAR de ce code HTML.

    Grand merci pour ton aide

    Bien cordialement
    Pierre

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. visualisation de la base sur une page web
    Par zorian dans le forum Access
    Réponses: 4
    Dernier message: 10/12/2005, 18h20
  2. Réponses: 2
    Dernier message: 30/11/2005, 11h19
  3. Recherche sur une page web
    Par Itori dans le forum Langage
    Réponses: 3
    Dernier message: 22/09/2005, 13h32
  4. Obtenir des infos sur une page web en ligne
    Par Logan_Cale dans le forum Web & réseau
    Réponses: 1
    Dernier message: 20/08/2005, 15h36
  5. application qui connecte sur une page web
    Par spoolz dans le forum Entrée/Sortie
    Réponses: 6
    Dernier message: 14/04/2004, 09h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo