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.
Code: Select all | Expand
// -------------------------------------------------------------------------- //function leeADDS()local sitelocal cad:=""local outlocal oWebClientlocal oTimer,oDlglocal cPagenamesite := "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():owndACTIVATE TIMER otimerDEFINE 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 centeredout:= fcreate("meteo.txt",0)fwrite(out,cad+CRLF)fclose(out)RELEASE TIMER otimerreturn nil// ---------------------------------------------------------------------------- //static function comprueba(cad)local bien:= .t.if !cad="HTTP/1.1 200 OK"bien:= .f.endifif !("</html>"$cad)bien:= .f.endifreturn bien
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