/*
Purpose: Example of how to get the HTML code for a web page
Date : 01/04/05
Notes : You must create a main window to use a socket.
I had to fix a bug in the TWebClient class, new method. It was returning nil
instead of self. TWEBCLIE.PRG was dated 11/11/1999 (came with FWH 2.4 July 2003).
The function ProcessPage does not return the code since it is collected in a socket
which may still be running when the function exits. You have to process the code
by assigning a function call to oWeb:oSocket:bClose
James Bott, jbott@compuserve.com
*/
#include "fivewin.ch"
#define FALSE .F.
#define TRUE .T.
function main()
local oWnd
define window oWnd
activate window oWnd ;
on init ProcessPage("http://www.nseindia.com/content/historical/EQUITIES/2006/APR/cm24APR2006bhav.csv")
return nil
function ProcessPage(cURL)
local oWeb
local cHTML:="" // contains HTML code
local cSite:=""
local cPage:=""
if left(upper(cURL),7) = "HTTP://"
cURL:= right(cURL,len(cURL)-7)
endif
cSite:= left(cURL, at("/",cURL)-1 )
cPage:= right(cURL,len(cURL)-at("/",cURL))
//msgInfo(cSite,"cSite")
//msgInfo(cPage,"cPage")
oWeb := TWebClient():New()
oWeb:oSocket:Cargo := FALSE
oWeb:bOnConnect = {|oWClient| oWClient:oSocket:Cargo := TRUE}
oWeb:bOnRead = {|cData| if(valtype(cData) == "C", cHTML += cData, )}
oWeb:Connect(cSite)
//msgInfo(cHTML)
// Keep trying to connect
while ! oWeb:oSocket:Cargo
WaitMessage()
SysRefresh()
enddo
// msgInfo("Connected to site")
oWeb:GetPage( cPage )
// Assign function to process code
oWeb:oSocket:bClose = {|self| ::end(), self:=Nil, Process(cHTML) }
//oWeb:oSocket:close()
sysrefresh()
//msgInfo("page collected")
//msgInfo(cHTML)
return nil
// Process the HTML code
function Process(cHTML)
msgInfo(cHTML,"HTML code") // for testing only
// Process the code here--save to file, extract data, etc.
return nil
// eof
//----------------------------------------------------------------------------//
Thanks for the program supplied for downloading the info from web page.When I ran that program I got the info displayed in a window.When I clicked the close button of the window I got following error message "Error BASE/1209 String Overflow: + from Errorsys,line:0".Pls advice how to overcome this problem.Is it occuring because info is more than 65K . I have noticed the CSV file size is between 65K-68K.If this is the case pls advice how to overcome this.
Return to FiveWin for CA-Clipper
Users browsing this forum: No registered users and 10 guests