Hola a todos
Estoy intentando obtener los datos del CLIMA del día.
Encontre esta página donde tecleando lo siguiente: http://wttr.in/Guadalajara+Jalisco
(puedes tratar con tu ciudad+estado) en el navegador, me despliega la informacion de la imagen siguiente.
La intención es obtener estos datos y mostrarlos en una ventana con HMG.
Alguna idea ??
*----------------------------------------------------------------------------------------------------------------------
Hi all
I'm trying to get the WEATHER data for the day.
I found this page where typing the following: http://wttr.in/Guadalajara+Jalisco
(you can try with your city + state) in the browser, it displays the information of the following image.
The intention is to obtain this data and display it in a window with HMG.
Any ideas ??
El Clima / The weather
Moderator: Rathinagiri
El Clima / The weather
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
- serge_girard
- Posts: 3166
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: El Clima / The weather
Andrés,
See little demo. It will return the HTML code, then you will extract yourself what you need.
That is how I extract my weather information!
Serge
See little demo. It will return the HTML code, then you will extract yourself what you need.
Code: Select all
HBC
inc=yes
head=native
libs=hbssl
libs=libeay32
libs=ssleay32
HBP
DEMO.PRG
hbssl.hbc
PRG
#include "hmg.ch"
#INCLUDE "Fileio.CH"
#require "hbtip"
#require "hbssl"
REQUEST __HBEXTERN__HBSSL__
FUNCTION MAIN()
/***********************/
LOCAL cURL, cHtml, vRet, cX1
XHTTP := 'http://wttr.in/Guadalajara+Jalisco'
cX1 := STRTRAN(XHTTP,'www.','')
cHtml := Read_URL( cX1 )
IF!EMPTY(cHtml)
vRet := Extract_IP(cHtml)
msginfo(vRet)
RETURN IIF(EMPTY(vRET), 'Site unreachable!', vRet)
ELSE
RETURN ''
ENDIF
FUNCTION Extract_IP(cHtml)
/***********************/
LOCAL Pos, PosF
Pos := AT('<BODY', UPPER(cHtml) )
// msginfo(cHtml ,'2')
IF Pos < 1
RETURN 0
ENDIF
cHtml := SUBSTR( cHtml, Pos+5 )
RETURN ALLTRIM(cHtml)
FUNCTION Read_URL( cUrl )
/***************************/
LOCAL oUrl, oCli, cRes := ''
BEGIN SEQUENCE
oUrl = TUrl():New( cUrl )
IF EMPTY( oUrl )
BREAK
ENDIF
oCli = TIpClientHttp():New( oUrl )
IF EMPTY( oCli )
BREAK
ENDIF
oCli:nConnTimeout = 20000
IF !oCli:Open( oUrl )
BREAK
ENDIF
cRes := oCli:Read()
oCli:Close()
END SEQUENCE
RETURN cRes
Serge
There's nothing you can do that can't be done...
- vagblad
- Posts: 160
- Joined: Tue Jun 18, 2013 12:18 pm
- DBs Used: MySQL,DBF
- Location: Thessaloniki, Greece
Re: El Clima / The weather
Serge was faster!
But since i prepared a little demo i'll post it as well
PS. Mind you its in MiniGUI but you can see how it works.
But since i prepared a little demo i'll post it as well
PS. Mind you its in MiniGUI but you can see how it works.
- Attachments
-
- Weather.zip
- (808.05 KiB) Downloaded 200 times
Vagelis Prodromidis
Email: vagblad@gmail.com, Skype: vagblad
Email: vagblad@gmail.com, Skype: vagblad
Re: El Clima / The weather
Hola Serge y Vagblad
Muchas Gracias por contestar !
Voy a probarlos
*------------------------------------------------------------------------------------------------------------
Hello Serge and Vagblad
Thank you very much for answering !
I'm going to try them
Muchas Gracias por contestar !
Voy a probarlos
*------------------------------------------------------------------------------------------------------------
Hello Serge and Vagblad
Thank you very much for answering !
I'm going to try them
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
Re: El Clima / The weather
Gracias de nuevo Serge
Ya hice una prueba y me despliega el HTML.
Adicionalmente, puse algunos parametros al link del clima
y suprime muchos "tags" facilitando el trabajo.
*-----------------------------------------------------------------------------------------
Thanks again Serge
I already did a test and it displays the HTML.
Additionally, I put some parameters to the weather link
and it suppresses many "tags" facilitating the work.
'http://wttr.in/Guadalajara+Jalisco?ptT&lang=es '
Ya hice una prueba y me despliega el HTML.
Adicionalmente, puse algunos parametros al link del clima
y suprime muchos "tags" facilitando el trabajo.
*-----------------------------------------------------------------------------------------
Thanks again Serge
I already did a test and it displays the HTML.
Additionally, I put some parameters to the weather link
and it suppresses many "tags" facilitating the work.
'http://wttr.in/Guadalajara+Jalisco?ptT&lang=es '
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
Re: El Clima / The weather
Hola a Todos, aquí les dejo un ejemplo actualizado por si a alguien le es util.
*--------------------------------------------------------------------------------------------
Hi Everyone, here is an updated example in case someone is useful.
*--------------------------------------------------------------------------------------------
Hi Everyone, here is an updated example in case someone is useful.
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.