Could someone show me how to save the content of a internet page to a variable.
Thanks in advance
Otto
Could someone show me how to save the content of a internet page to a variable.
Thanks in advance
Otto
FUNCTION MAIN()
? GETURL( "http://www.emagsoftware.it/gratis.htm" )
RETURN NIL
FUNCTION GETURL( cUrl )
LOCAL cFile := SUBSTR( cUrl, RAT( "/", cUrl ) + 1 )
LOCAL oUrl, oCli
LOCAL lOk := .F.
BEGIN SEQUENCE
oUrl = TUrl():New( cUrl )
IF EMPTY( oUrl ); BREAK; ENDIF
oCli = TIPClientHttp():New( oUrl )
IF EMPTY( oCli ); BREAK; ENDIF
IF !oCli:Open(); BREAK; ENDIF
IF !oCli:ReadToFile( cFile ); BREAK; ENDIF
lOk = "OK" $ UPPER( oCli:cReply )
oCli:Close()
IF !lOk; FERASE( cFile ); ENDIF
END SEQUENCE
RETURN lOkHello Enrico,
thank you for your help.
Should your code also work on a password protected page.
Is cFile the content of the page.
Thanks in advance
Otto
Hello Enrico,
Thank you again. With trial and error I found out how to do.
If someone is interested:
oDoc := oActiveX:GetProp( "Document" )
oText := oDoc:GET("body" )
msginfo( oText:GET("innerText" ))
Best regards,
Otto