FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to get http response text
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: How to get http response text
Posted: Sun Oct 11, 2020 11:56 AM

Could the failure be connected to the popup that shows the cookies acceptance message when one loads the page for the 1st time?

Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to get http response text
Posted: Sun Oct 11, 2020 12:12 PM
Prova questo esempio:

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL cUrl := "https://www.nonsolocap.it/cap?k=calori&b=&c=bologna"

    LOCAL cRes := GETURL( cUrl )

    MEMOWRIT( "Response_Test.htm", cRes, .F. )

    RETURN NIL


#command IF <condition> THEN <*statements*> => if <condition> ; <statements> ; end


STATIC FUNCTION GETURL( cUrl, oHtp )

    LOCAL cRes

    TRY
        DEFAULT oHtp := CREATEOBJECT( "MSXML2.XMLHTTP" )

        oHtp:Open( "GET", cUrl, .F. )

        oHtp:Send()

        IF oHtp:Status != 200 THEN BREAK

        cRes = oHtp:ResponseText
    CATCH
    END

    RETURN cRes


EMG
Posts: 37
Joined: Mon Jun 29, 2015 07:41 AM
Re: How to get http response text
Posted: Sun Oct 11, 2020 03:22 PM
Enrico Maria Giordano wrote:Prova questo esempio:

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL cUrl := "https://www.nonsolocap.it/cap?k=calori&b=&c=bologna"

    LOCAL cRes := GETURL( cUrl )

    MEMOWRIT( "Response_Test.htm", cRes, .F. )

    RETURN NIL


#command IF <condition> THEN <*statements*> => if <condition> ; <statements> ; end


STATIC FUNCTION GETURL( cUrl, oHtp )

    LOCAL cRes

    TRY
        DEFAULT oHtp := CREATEOBJECT( "MSXML2.XMLHTTP" )

        oHtp:Open( "GET", cUrl, .F. )

        oHtp:Send()

        IF oHtp:Status != 200 THEN BREAK

        cRes = oHtp:ResponseText
    CATCH
    END

    RETURN cRes


EMG


Ok, perfect , this is the solution.
Probably it was a memory leak or conflict, so by saving the oHtp:ResponseText in a file and then use a memoread to retrieve, the problem is SOLVED.
Thank You very much Enrico.

Lorenzo
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to get http response text
Posted: Sun Oct 11, 2020 04:27 PM
Can you try with this and let me know?

Code (fw): Select all Collapse
? GETURL( cUrl )


EMG

Continue the discussion