Buenas tardes
Estoy intentado leer una página web desde mi programa. La página es
http://aviationweather.gov/adds/metars/index.php?submit=1&station_ids=LEAL&chk_metars=on&chk_tafs=on&hoursStr=3
El siguente código me funciona perfectamente con páginas que no son php.
Pero como ésta es php me da un error. No he encontrado nada en el foro al respecto. ¿Alguien me puede echar una mano?
Muchas gracias y un saludo,
Alvaro
Estoy intentado leer una página web desde mi programa. La página es
http://aviationweather.gov/adds/metars/index.php?submit=1&station_ids=LEAL&chk_metars=on&chk_tafs=on&hoursStr=3
El siguente código me funciona perfectamente con páginas que no son php.
// -------------------------------------------------------------------------- //
function leeADDS()
local site
local cad:=""
local out
local oWebClient
local oTimer,oDlg
local cPagename
site := "aviationweather.gov"
cPagename:= "/adds/metars/index.php?submit=1&station_ids=LEAL&chk_metars=on&chk_tafs=on&hoursStr=3"
oWebClient := TWebClient():New()
oWebClient:Connect( site )
DEFINE TIMER otimer INTERVAL 1000 ACTION if(comprueba(cad) , oDlg:end() , nil) OF app():ownd
ACTIVATE TIMER otimer
DEFINE DIALOG oDlg FROM 3, 3 TO 28, 79 title "Espera "+cPageName
// oWebClient:bOnConnect = { || MsgInfo( "Connected!" ) }
// oWebClient:bOnRead = { | cData | cad += cData }
oWebClient:bOnRead = { | cData | cad += cData }
oWebClient:oSocket:SendData( "GET " + cPageName + " HTTP/1.0" + CRLF +"Host: "+site+ CRLF +CRLF )
activate dialog oDlg centered
out:= fcreate("meteo.txt",0)
fwrite(out,cad+CRLF)
fclose(out)
RELEASE TIMER otimer
return nil
// ---------------------------------------------------------------------------- //
static function comprueba(cad)
local bien:= .t.
if !cad="HTTP/1.1 200 OK"
bien:= .f.
endif
if !("</html>"$cad)
bien:= .f.
endif
return bienPero como ésta es php me da un error. No he encontrado nada en el foro al respecto. ¿Alguien me puede echar una mano?
Muchas gracias y un saludo,
Alvaro