Read_CSV_Data_from_Website Please help
Posted: Sun Jun 11, 2006 11:24 pm
I tried the program 'Read_CSV_Data_from_Website.pb' listed in the CodeArchiv data base, and can't seem to get it to work. I used the convert 3.94 to 4.0 , and added some Debug commands to it as listed in the listed source, as well as some command info from the help file.
InitNetwork() does = 1, but ConnectionID always = 0. I also tried different addresses. The help file lists those commands and would seem to indicate that it should work. Could some one please tell me what's wrong or why it dosen't work. What I am looking for, is just what the program seems it should be able to do. And that is to download stock data. I'm writing a stock chart program, and need a good way to interface with an internet site to download the entered stocks data. Thanks for any help and suggestions. Or if there may be a better way of doing it, I would really appreciate your help and suggestions.
InitNetwork() does = 1, but ConnectionID always = 0. I also tried different addresses. The help file lists those commands and would seem to indicate that it should work. Could some one please tell me what's wrong or why it dosen't work. What I am looking for, is just what the program seems it should be able to do. And that is to download stock data. I'm writing a stock chart program, and need a good way to interface with an internet site to download the entered stocks data. Thanks for any help and suggestions. Or if there may be a better way of doing it, I would really appreciate your help and suggestions.
Code: Select all
; Converted by PBSourceConverter on 11.06.2006 / 16:42
; English forum: http://purebasic.myforums.net/viewtopic.php?t=6642&highlight=
; Author: ricardo
; Date: 20. June 2003
result=InitNetwork()
;This command must be called before any other command from the Network library.
;If the 'Result is 0, there is no TCP/IP stack available on the system
Debug "InitNetwork() = " +Str(result)
ConnectionID = OpenNetworkConnection("table.finance.yahoo.com", 80)
;Connection = OpenNetworkConnection(ServerName$, Port [, Mode])
;'ServerName$' can be an IP address or a full name (ie: "127.0.0.1" or "ftp.home.net").
Debug "ConnectionID = " +Str(ConnectionID)
If ConnectionID
com$="GET http://table.finance.yahoo.com/table.csv?s=IBM&g=d HTTP/1.1"+Chr(13)+Chr(10)
com$=com$+"Accept: */*"+Chr(13)+Chr(10)
com$=com$+"Accept: text/html"+Chr(13)+Chr(10)
com$=com$+"Host: "+host$+Chr(13)+Chr(10)
com$=com$+"User-Agent: Yahoo CVS Parser"+Chr(13)+Chr(10)
com$=com$+Chr(13)+Chr(10)
Res = SendNetworkData(ConnectionID,@com$,Len(com$))
Repeat
Delay(10)
Result = NetworkClientEvent(ConnectionID)
Debug "NetworkClientEvent(ConnectionID) = " +Str(Result)
Select Result
Case 2
Content$ = Space(14500)
ReceiveNetworkData(ConnectionID,@Content$,14500)
Ok = 1
MessageRequester("Done!","Your Data" + Chr(13) + Chr(10) + Content$,0)
CloseNetworkConnection(ConnectionID)
EndSelect
Until Ok = 1
EndIf
; ExecutableFormat=Windows
; FirstLine=1
; EOF