FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour oActivex navigate2
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
oActivex navigate2
Posted: Fri Feb 20, 2009 11:09 PM

Could someone show me how to save the content of a internet page to a variable.
Thanks in advance
Otto

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: oActivex navigate2
Posted: Sat Feb 21, 2009 07:24 AM
This is a working sample:

Code (fw): Select all Collapse
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 lOk


EMG
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: oActivex navigate2
Posted: Sat Feb 21, 2009 07:49 AM

Hello 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

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: oActivex navigate2
Posted: Sat Feb 21, 2009 09:35 AM

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

Continue the discussion