I wrote a program to download text files from the National Stock Exchange. This is the download function:
downloadNseBhav: func [Date] [
NSE_Url: to-url rejoin [
"http://nseindia.com/content/historical/EQUITIES/"
(uppercase form-date Date "%Y/%b/") "cm" Sd "bhav.csv.zip"
; format NSE Bhavcopy url
]
either error? try [
write/binary to-file rejoin ["./NSE/" Sd "bhav.csv.zip"]
read/binary NSE_Url
; download bhavcopy zip file to disk in ./NSE folder
][
append Log/text "Server made a boo boo ......NSE Bhavcopy not found^/^/"
scroll-text Log
Exit
][
append Log/text "Downloaded NSE Bhavcopy Zip^/"
scroll-text Log
]
]
I get the file with the message not found many times, although the required file is. This is annoying when multiple files are requested and some of them do not load. I get the file if I try again.
I read the command waitin the Rebol 2 documentation and found that, by default, a wait is performed to open the port. What am I doing wrong? Is there a way to make Rebol wait a couple of seconds to get a response from the server?
-
. , 10 ( 1 10 ). . , . . .
,
- 10 , tomc.
- ,
Wireshark, Hostilfork, , .
either error? err: try [ BC: read/binary NSE_Url ] ; download bhavcopy zip file to disk in ./NSE folder
[ err: disarm err
probe err
write/append %log.txt rejoin ["NSE EQUITIES/bhavcopy not found " DateYmd "^/"]
Exit
] []
]
1 DEC 2015 15 DEC 2015.
-
NSE EQUITIES/bhavcopy not found 2015-12-08
NSE EQUITIES/bhavcopy not found 2015-12-09
-
NSE EQUITIES/bhavcopy not found 2015-12-01
NSE EQUITIES/bhavcopy not found 2015-12-02
-
emake object! [
code: 507
type: 'access
id: 'no-connect
arg1: "nseindia.com"
arg2: none
arg3: none
near: [BC: read/binary NSE_Url]
where: 'open-proto
]
, . Rebol.
, . 8 /, .
Rebol google.co.in
-
test: read http:// google . co. in
Access Error: Cannot connect to google.co.in
Where: open-proto
Near: test: read http://google.co.in
test: read http://google.co.in
== {<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en-IN"><head><meta content="text/html; charset=UTF...
.
, - :
either error? err: try [
write/binary to-file rejoin ["./NSE/" Sd "bhav.csv.zip"]
read/binary NSE_Url]
, , , Rebol2 - err: .