oActivex navigate2

oActivex navigate2

Postby Otto » 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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: oActivex navigate2

Postby Enrico Maria Giordano » Sat Feb 21, 2009 7:24 am

This is a working sample:

Code: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: oActivex navigate2

Postby Otto » Sat Feb 21, 2009 7: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: oActivex navigate2

Postby Otto » Sat Feb 21, 2009 9: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 72 guests