Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Help saving results from function on local webserver...
Pages: [1] Print
Author Topic: Help saving results from function on local webserver...  (Read 820 times)
revel
Newbie
*
Offline Offline

Posts: 6


View Profile
Help saving results from function on local webserver...
« on: June 25, 2006, 01:41:30 PM »

Hi,

I've a local application webserver which returns a result of trade data when the following command is entered in the browser address.

http://127.0.0.1:16239/req?GetHistory(kse:@ksu6,0,0,1D)

How do i store the result of the above command in rebol?

What should i modify from this code?
data: read http://127.0.0.1:16239/req?GetHistory(kse:@ksu6,0,0,1D)


Thanks
Logged
Graham
Full Member
***
Offline Offline

Posts: 113


View Profile
Re: Help saving results from function on local webserver...
« Reply #1 on: June 25, 2006, 11:11:57 PM »

data contains the result of you read operation.

If you want to save it, just write it to your local drive

write %saved.txt data

should do it ...
Logged

revel
Newbie
*
Offline Offline

Posts: 6


View Profile
Re: Help saving results from function on local webserver...
« Reply #2 on: June 26, 2006, 12:53:03 AM »

Hi,

Thanks for the reply. I should have asked the question better and in this case store was the wrong word. What I was trying to say was that the above code does not return the trade results and thus incorrect.

in the browser, this is entered
http://127.0.0.1:16239/req?GetHistory(kse:@ksu6,0,0,1D)

which then returns

OK
09/13/2005,150.10,150.10,149.05,149.40,3
09/14/2005,150.50,152.50,150.50,152.50,2
09/15/2005,152.55,152.55,152.55,152.55,1
09/21/2005,154.85,154.85,154.85,154.85,1
09/22/2005,154.60,154.60,154.60,154.60,1
09/26/2005,152.00,156.00,152.00,156.00,3
09/27/2005,155.60,155.60,155.50,155.50,2
09/28/2005,157.30,158.00,156.85,158.00,3
09/29/2005,158.00,158.90,158.00,158.90,3
10/04/2005,159.85,160.90,159.85,160.90,2
10/05/2005,158.30,158.30,157.20,157.20,5
10/06/2005,154.30,154.30,154.20,154.20,2
10/07/2005,154.60,154.60,154.50,154.50,2
10/11/2005,157.90,159.10,157.20,159.10,3

in rebol, when entering in console
>> data: read http://127.0.0.1:16239/req?GetHistory(kse:@ksu6,0,0,1D)
== kse:@ksu6,0,0,1D
>> print data
Error: requires 4 arguments
>>

It does not return the expected trade data from the running local server. I suspect it may be due to the ( ) in the url which causes the problem but I;m not quite sure how to solve that

Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
Re: Help saving results from function on local webserver...
« Reply #3 on: June 26, 2006, 03:26:08 AM »

Code:
data: read http://127.0.0.1:16239/req?GetHistory%28kse:@ksu6,0,0,1D%29

You just need to escape the parens with %28 and %29.
Logged
revel
Newbie
*
Offline Offline

Posts: 6


View Profile
Re: Help saving results from function on local webserver...
« Reply #4 on: June 26, 2006, 04:56:40 AM »

Hi,

Not quite there yet. It seems that the @ sign is in the way.  Not sure whether the other remaining punctuations like : or , will affect as well.


>> data: read http://127.0.0.1:16239/req?GetHistory%28kse:@ksu6,0,0,1D%29
** Access Error: Cannot connect to ksu6,0,0,1D
** Where: open-proto
** Near: data: read http://127.0.0.1:16239/req?GetHistory%28kse:@ksu6,0,0,1D%29
>>



This is what I tried, which from to-url gave the same escape %28 and %29 as you mentioned. However, it seems the @ and perhaps other punctuation are causing confusion.


>> weburl: to-url http://127.0.0.1:16239/req?GetHistory(kse:@ksu6,0,0,1D)
== http://127.0.0.1:16239/req?GetHistory%28kse:@ksu6,0,0,1D%29
>> read weburl
** Access Error: Cannot connect to ksu6,0,0,1D
** Where: open-proto
** Near: read weburl
>> print weburl
http://127.0.0.1:16239/req?GetHistory(kse:@ksu6,0,0,1D)
« Last Edit: June 26, 2006, 05:15:36 AM by revel » Logged
revel
Newbie
*
Offline Offline

Posts: 6


View Profile
Re: Help saving results from function on local webserver...
« Reply #5 on: June 26, 2006, 05:27:08 AM »

Just tried a simpler ticker symbol ie qqqq and it works

>> weburl: to-url "http://127.0.0.1:16239/req?GetHistory(qqqq,0,0,1D)"
== http://127.0.0.1:16239/req?GetHistory%28qqqq,0,0,1D%29
>> data: read weburl
== {OK
06/21/2005,37.83,38.01,37.70,37.85,90041500
06/22/2005,38.00,38.10,37.63,37.83,72538200
06/23/2005,37.89,38.18,37.33,37.37,1...
>> print data
OK
06/21/2005,37.83,38.01,37.70,37.85,90041500
06/22/2005,38.00,38.10,37.63,37.83,72538200
06/23/2005,37.89,38.18,37.33,37.37,114012800
06/24/2005,37.38,37.41,36.96,36.96,136221600
.
.
.
etc


so a simple ticker symbol like qqqq works fine, however the more complex ticker symbol kse:@ksu6 returns errors as mentioned above...

Logged
Gord
Newbie
*
Offline Offline

Posts: 18


View Profile
Re: Help saving results from function on local webserver...
« Reply #6 on: June 26, 2006, 11:17:44 AM »

My guess is that the username, password and host site are not being transferred properly in the url.  I have seen a syntax similar to the following:

username:password@URL

and the full URL that you gave us seems to be missing the password after the colon and URL after the "@" sign, (although I guess the "ksu6" could be the URL with the 0,0,1D as additional parameters).  In this case the interpreter is trying to use "ksu6,0,0,1D" as the URL with no parameters.


Logged
revel
Newbie
*
Offline Offline

Posts: 6


View Profile
Re: Help saving results from function on local webserver...
« Reply #7 on: June 26, 2006, 08:42:34 PM »

hi,

it would seem that there's probably some convention such as that which you mentioned or perhaps just email@domain.com which causes rebol interpreter to not pass the full string as is and instead attempts to interpret the @ sign.

the local webserver application has a few functions with defined parameters. there is no password required as a parameter in this case. at least with a simple ticker symbol like qqqq it works.

Is there a way to escape the @ character like for the ( ) . the to-url function will not convert the @ character as oftentimes that would be the desired behaviour.

Is there a generic way to handle this scenario of ticker symbols with "special" punctuations  in them? Another ticker symbol format has the # instead of the @.
Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
Re: Help saving results from function on local webserver...
« Reply #8 on: June 27, 2006, 05:38:18 AM »

I'm not sure if @ is allowed in URL paths. Anyway, a general solution is:

Code:
read [
    scheme: 'http
    host: 127.0.0.1
    port-id: 16239
    target: "/req?GetHistory(kse:@ksu6,0,0,1D)"
]

or maybe:

Code:
read [
    scheme: 'http
    host: 127.0.0.1
    port-id: 16239
    path: "/"
    target: "req?GetHistory(kse:@ksu6,0,0,1D)"
]

This way you bypass REBOL's URL parsing completely.
Logged
revel
Newbie
*
Offline Offline

Posts: 6


View Profile
Re: Help saving results from function on local webserver...
« Reply #9 on: June 28, 2006, 07:36:01 AM »

Hi,

Yes it finally works. I removed the / in the target string. Other then that everything seems just fine. Thanks !

data: read [
[        scheme: 'http
[        host: 127.0.0.1
[        port-id: 16239
[        target: "req?GetHistory(kse:@ksu6,0,0,1D)"
[    ]
connecting to: 127.0.0.1
== {OK
09/13/2005,150.10,150.10,149.05,149.40,3
09/14/2005,150.50,152.50,150.50,152.50,2
09/15/2005,152.55,152.55,152.55,152.55,1
0...
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Help saving results from function on local webserver...
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 21, 2008, 01:40:40 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2293 Posts in 593 Topics by 3749 Members
Latest Member: irotlydor

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc