URL-Query
[1/9] from: D:Weyand:gmx at: 25-Feb-2005 10:42
Hi list,
does anybody know a workaround to handle URIs with a escape character ^
like
http://ichart.yahoo.com/table.csv?s=^DJI&a=1&b=26&c=2004&d=1&e=25&f=2005&g=d&ignore=.csv
within REBOL?
>> read
http://ichart.yahoo.com/table.csv?s=^DJI&a=1&b=26&c=2004&d=1&e=25&f=2005&g=d&ignore=.csv
** User Error: URL error:
http://ichart.yahoo.com/table.csv?s=^DJI&a=1&b=26&c=2004&d=1&e=25&f=2005&g=d&ign
ore=.csv
** Near: read
http://ichart.yahoo.com/table.csv?s=^DJI&a=1&b=26&c=2004&d=1&e=25&f=2005&g=d&ignore=.csv
I need your advice and help.
Regards Dirk
--
DSL Komplett von GMX +++ Supergünstig und stressfrei einsteigen!
AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl
[2/9] from: SunandaDH:aol at: 25-Feb-2005 5:08
Dirk:
> does anybody know a workaround to handle URIs with a escape character ^
> like
escape it as %5E
Keep it as a string until you need it:
u:
{http://ichart.yahoo.com/table.csv?s=%5eDJI&a=1&b=26&c=2004&d=1&e=25&f=2005&g=d&ignore=.csv}
read to-url u
== {Date,Open,High,Low,Close,Volume,Adj. Close*
24-Feb-05,10672.24,10779.39,10612.24,10748.79,15187500,10748.79
23-Feb-05,10609.28,... [snip]
Sunanda.
[3/9] from: D:Weyand:gmx at: 25-Feb-2005 11:56
Thanks Sunanda,
:-)
--
Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS
GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail
[4/9] from: hallvard:ystad:oops-as:no at: 25-Feb-2005 12:50
Replace the "^" with "^^".
You may want to look at my url-handler script:
http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?color=yes&script=url-handler.r
I'll put the "^^" trick into it shortly.
HY
Dixit Dirk Weyand (10.42 25.02.2005):
[5/9] from: Izkata:Comcast at: 25-Feb-2005 6:00
Didn't work when I tried.....
-Izzy Boy
[6/9] from: hallvard:ystad:oops-as:no at: 25-Feb-2005 13:05
Thinking about it, this escaping needs to be done before you pass the string to the url-handler,
so don't wait up for an update...
HY
Dixit Hallvard Ystad (12.50 25.02.2005):
[7/9] from: hallvard:ystad:oops-as:no at: 25-Feb-2005 22:44
Sorry, my fault.
You should, of course, replace the "^" with "%5E" ! Save the original URL to a file called
"url" and then do this:
a: read %url
print read to-url replace/all a "^^" "%5E"
Works overe here, should work fine for you too.
HY
Dixit Izkata (13.00 25.02.2005):
>Didn't work when I tried.....
> -Izzy Boy
<<quoted lines omitted: 8>>
>> You may want to look at my url-handler script:
>> http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?color=yes&script=
[8/9] from: antonr:lexicon at: 26-Feb-2005 15:40
I don't see the need to save to and read from a file.
You can do it all in memory, eg:
>> url:
http://ichart.yahoo.com/table.csv?s=^DJI&a=1&b=26&c=2004&d=1&e=25&f=2005&g=d
&ignore=.csv
==
http://ichart.yahoo.com/table.csv?s=^DJI&a=1&b=26&c=2004&d=1&e=25&f=2005&g=d
&ignore=.csv
>> url2: copy url
==
http://ichart.yahoo.com/table.csv?s=^DJI&a=1&b=26&c=2004&d=1&e=25&f=2005&g=d
&ignore=.csv
>> replace/all url2 "^^" "%5E"
==
http://ichart.yahoo.com/table.csv?s=%5EDJI&a=1&b=26&c=2004&d=1&e=25&f=2005&g
=d&ignore=.csv
>> read url2
== {Date,Open,High,Low,Close,Volume,Adj. Close*
25-Feb-05,10748.42,10871.53,10698.32,10841.60,15236800,10841.60
24-Feb-05,10672.24,...
Anton.
[9/9] from: hallvard:ystad-oops:as:no at: 26-Feb-2005 13:16
Dixit Anton Rolls (05.40 26.02.2005):
>I don't see the need to save to and read from a file.
>You can do it all in memory [...]
Of course. But make sure you don't serve to the rebol scanner a string that will be scanned
before the URL is constructed. This is OK:
>> url: http://ichart.yahoo.com/table.csv?s=^DJI&a=1&b=26&c=2004&d=1&e==
25&f=2005&g=d&ignore=.csv
>> url
===
http://ichart.yahoo.com/table.csv?s=^DJI&a=1&b=26&c=2004&d=1&e==
25&f=2005&g=d&ignore=.csv
But this is not:
>> url: to-url "http://ichart.yahoo.com/table.csv?s=^DJI&a=1&b=26&c=2004&d=1&e=25&f=2005&g=d&ignore=.csv"
>> url
===
http://ichart.yahoo.com/table.csv?s=%04JI&a=1&b=26&c=2004&d=1&e=25&f=2005&g=d&ignore=.csv
The reason is that rebol has found "^D" to be %04 instead of #"^" alone to be %5E. You
need to replace #"^" before the rebol scanner gets a chance to find it.
Maybe this is worth a mention to RT feedback? Maybe 'read should be able to fix #"^"
on its own?
HY
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted