How to get http response text
Re: How to get http response text
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 BCC 5.82 MinGW 4.5.2 MSVS 10
André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: How to get http response text
Prova questo esempio:
EMG
Code: Select all
#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
-
- Posts: 28
- Joined: Mon Jun 29, 2015 7:41 am
Re: How to get http response text
Ok, perfect , this is the solution.Enrico Maria Giordano wrote:Prova questo esempio:
EMGCode: Select all
#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
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
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: How to get http response text
Can you try with this and let me know?
EMG
Code: Select all
? GETURL( cUrl )