Pls help, want to download quotes.csv file from
:"//finance.yahoo.com/d/quotes.csv?s=BBDB.TO+NT.TO+GE+MSFT&f=snl1d1t1ohgdr"
with thanks
(xharbour/FWH)
Download stock quote file from yahoo
Try this,
TWebsrc.prg
Code: Select all
#include "fivewin.ch"
Function Main()
local ws:=TdWebService():new()
? ws:OpenWS("http://finance.yahoo.com/d/quotes.csv?s=BBDB.TO+NT.TO+GE+MSFT&f=snl1d1t1ohgdr")
ws:end()
return nil
Code: Select all
#include "dll.ch"
static xdll
*****************************
CLASS TdWebService
DATA hOpen
DATA sbuffer HIDDEN
DATA xDLL HIDDEN
METHOD New(buffersize) CONSTRUCTOR
METHOD OpenWS(url)
METHOD End()
ENDCLASS
*****************************
METHOD New(conexion,buffersize) CLASS TdWebService
DEFAULT buffersize:=64000
::sbuffer:=buffersize
xDll:=LoadLib32("wininet.dll")
::hOpen = InternetOpen("TdWebService", 1,,, 0)
RETURN Self
*****************************
METHOD OpenWS(url) CLASS TdWebService
local hFile,ret,xml
hFile = InternetOpenUrl(::hOpen, url,"",0,,0)
xml:=space(::sbuffer)
InternetReadFile(hFile, @xml, ::sbuffer, @Ret)
return subst(alltrim(xml),1,len(alltrim(xml))-5)
*****************************
METHOD End() CLASS TdWebService
FreeLib32(xDll)
return nil
*****************************
DLL32 FUNCTION InternetOpen( cApp as LPSTR, n1 AS DWORD, n2 AS LPSTR, n3 AS LPSTR,;
n4 AS DWORD ) AS LONG PASCAL ;
FROM "InternetOpenA" LIB xdll
Dll32 Function InternetReadFile(hFile As 7, @sBuffer As 8, lNumBytesToRead As 7, @lNumberOfBytesRead As 7) As 7 PASCAL Lib xdll
Dll32 Function InternetOpenUrl(hInternetSession As 7, lpszUrl As 8, lpszHeaders As 8, dwHeadersLength As 7, dwFlags As 7, dwContext As 7) As 7 FROM "InternetOpenUrlA" PASCAL Lib xdll
DLL32 FUNCTION InternetCloseHandle( hSession AS LONG ) AS BOOL PASCAL LIB xdll
Friend,
Try now:
Try now:
Code: Select all
#include "fivewin.ch"
#include "dll.ch"
static xDLL // Need to TdWebService
static oGet,oSay
Function Main()
local ws:=TdWebService():new()
? ws:OpenWS("http://finance.yahoo.com/d/quotes.csv?s=BBDB.TO+NT.TO+GE+MSFT&f=snl1d1t1ohgdr")
ws:end()
return nil
CLASS TdWebService
DATA hOpen
DATA sbuffer HIDDEN
DATA xDLL HIDDEN
METHOD New(buffersize) CONSTRUCTOR
METHOD OpenWS(url)
METHOD End()
ENDCLASS
METHOD New(conexion,buffersize) CLASS TdWebService
DEFAULT buffersize:=64000
::sbuffer:=buffersize
xDll:=LoadLib32("wininet.dll")
::hOpen = InternetOpen("TdWebService", 1,,, 0)
RETURN Self
METHOD OpenWS(url) CLASS TdWebService
local hFile,ret,xml
hFile = InternetOpenUrl(::hOpen, url,"",0,,0)
xml:=space(::sbuffer)
InternetReadFile(hFile, @xml, ::sbuffer, @Ret)
return subst(alltrim(xml),1,len(alltrim(xml))-5)
METHOD End() CLASS TdWebService
FreeLib32(xDll)
return nil
DLL32 FUNCTION InternetOpen( cApp as LPSTR, n1 AS DWORD, n2 AS LPSTR, n3 AS LPSTR,;
n4 AS DWORD ) AS LONG PASCAL ;
FROM "InternetOpenA" LIB xdll
Dll32 Function InternetReadFile(hFile As 7, @sBuffer As 8, lNumBytesToRead As 7, @lNumberOfBytesRead As 7) As 7 PASCAL Lib xdll
Dll32 Function InternetOpenUrl(hInternetSession As 7, lpszUrl As 8, lpszHeaders As 8, dwHeadersLength As 7, dwFlags As 7, dwContext As 7) As 7 FROM "InternetOpenUrlA" PASCAL Lib xdll
DLL32 FUNCTION InternetCloseHandle( hSession AS LONG ) AS BOOL PASCAL LIB xdll
Still get the same error messages. Are we use the same version . I also use FWH 7.12. Thanks again.
xHarbour Compiler build 1.1.0 (SimpLex)
Copyright 1999-2007, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'quote.prg'...
quote.prg(9) Error E0016 Syntax error: '?'
quote.prg(14) Error E0030 Syntax error: "parse error at 'HOPEN'"
quote.prg(15) Error E0030 Syntax error: "parse error at 'SBUFFER'"
quote.p?rg(16) Error E0030 Syntax error: "parse error at 'XDLL'"
quote.prg(18) Error E0030 Syntax error: "parse error at 'NEW'"
quote.prg(20) Error E0030 Syntax error: "parse error at 'OPENWS'"
quote.prg(22) Error E0030 Syntax error: "parse error at 'END'"
quote.prg(23) Error E0030 Syntax error: "parse error at 'TO'"
quote.prg(26) Error E0030 Syntax error: "parse error at 'BUFFERSIZE'"
quote.prg(32) Error E0019 #error: 'Method "OpenWS(url)" not declared in class: TdWebService'
quote.prg(39) Error E0019 #error: 'Method "End()" not declared in class: TdWebService'
quote.prg(46) Error E0030 Syntax error: "parse error at 'FUNCTION'"
12 errors
No code generated
xHarbour Compiler build 1.1.0 (SimpLex)
Copyright 1999-2007, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'quote.prg'...
quote.prg(9) Error E0016 Syntax error: '?'
quote.prg(14) Error E0030 Syntax error: "parse error at 'HOPEN'"
quote.prg(15) Error E0030 Syntax error: "parse error at 'SBUFFER'"
quote.p?rg(16) Error E0030 Syntax error: "parse error at 'XDLL'"
quote.prg(18) Error E0030 Syntax error: "parse error at 'NEW'"
quote.prg(20) Error E0030 Syntax error: "parse error at 'OPENWS'"
quote.prg(22) Error E0030 Syntax error: "parse error at 'END'"
quote.prg(23) Error E0030 Syntax error: "parse error at 'TO'"
quote.prg(26) Error E0030 Syntax error: "parse error at 'BUFFERSIZE'"
quote.prg(32) Error E0019 #error: 'Method "OpenWS(url)" not declared in class: TdWebService'
quote.prg(39) Error E0019 #error: 'Method "End()" not declared in class: TdWebService'
quote.prg(46) Error E0030 Syntax error: "parse error at 'FUNCTION'"
12 errors
No code generated
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Otto,
Put this code:
Note: The credits for de TWebService Class is not for me.
Put this code:
Code: Select all
#include "fivewin.ch"
#include "dll.ch"
static xDLL // Need to TdWebService
static oGet,oSay
Function Main()
local oDlg,oFont,WhatQuote:=space(50)
local cResult := "Samples:" + CRLF + CRLF + "IBM" + CRLF + "MSFT+NO.TO" + CRLF + "DOW+MSFT+IBM"
DEFINE FONT oFont NAME "ARIAL" SIZE 00,-12 BOLD
DEFINE DIALOG oDlg TITLE "Push Quotes from Yahoo Finance" FROM 00,00 to 23,80 FONT oFont
@ 0.6,01 say "Get Quotes: " of oDlg
@ 0.5,5.5 get oGet var WhatQuote pict "@!" of oDlg
@ 0.3,43 button "Push" size 44,12 of oDlg ACTION Consulta(WhatQuote)
@ 02,01 to 12,44 LABEL "Resultado da pesquisa" of oDlg
@ 2.5,2.2 say oSay var cResult size 290,125 of oDlg color nRGB(255,0,0),getsyscolor(15)
ACTIVATE DIALOG oDlg CENTERED
return nil
Function Consulta(WhatQuote)
local ws:=TdWebService():new()
cQuotes := ws:OpenWS("http://finance.yahoo.com/d/quotes.csv?s="+WhatQuote+"&f=snl1d1t1ohgdr")
oSay:settext( cQuotes )
ws:end()
return nil
//static xdll
CLASS TdWebService
DATA hOpen
DATA sbuffer HIDDEN
DATA xDLL HIDDEN
METHOD New(buffersize) CONSTRUCTOR
METHOD OpenWS(url)
METHOD End()
ENDCLASS
METHOD New(conexion,buffersize) CLASS TdWebService
DEFAULT buffersize:=64000
::sbuffer:=buffersize
xDll:=LoadLib32("wininet.dll")
::hOpen = InternetOpen("TdWebService", 1,,, 0)
RETURN Self
METHOD OpenWS(url) CLASS TdWebService
local hFile,ret,xml
hFile = InternetOpenUrl(::hOpen, url,"",0,,0)
xml:=space(::sbuffer)
InternetReadFile(hFile, @xml, ::sbuffer, @Ret)
return subst(alltrim(xml),1,len(alltrim(xml))-5)
METHOD End() CLASS TdWebService
FreeLib32(xDll)
return nil
DLL32 FUNCTION InternetOpen( cApp as LPSTR, n1 AS DWORD, n2 AS LPSTR, n3 AS LPSTR,;
n4 AS DWORD ) AS LONG PASCAL ;
FROM "InternetOpenA" LIB xdll
Dll32 Function InternetReadFile(hFile As 7, @sBuffer As 8, lNumBytesToRead As 7, @lNumberOfBytesRead As 7) As 7 PASCAL Lib xdll
Dll32 Function InternetOpenUrl(hInternetSession As 7, lpszUrl As 8, lpszHeaders As 8, dwHeadersLength As 7, dwFlags As 7, dwContext As 7) As 7 FROM "InternetOpenUrlA" PASCAL Lib xdll
DLL32 FUNCTION InternetCloseHandle( hSession AS LONG ) AS BOOL PASCAL LIB xdll