[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

open-uri and illegal url characters

bsagert

6/6/2008 7:57:00 PM

Hello, n00b here. I use open-uri to read a Yahoo .csv file of stock
and index quotes. Yahoo indices start with a circumflex ("^") which a
browser will convert to "%5e". The following line is rejected by Yahoo
(andRuby) ==>s=open('http://download.finance...
/d/quotes.csv?s=^DJI,^SPX,^IXIC&f=sl1d1t1nohgv&e=.csv').read
Is there a Ruby method that will automatically convert illegal
characters into url-speak? Thanks, Bill
3 Answers

bsagert

6/6/2008 8:00:00 PM

0

On Jun 6, 12:56 pm, bsag...@gmail.com wrote:
> Hello, n00b here. I use open-uri to read a Yahoo .csv file of stock
> and index quotes. Yahoo indices start with a circumflex ("^") which a
> browser will convert to "%5e". The following line is rejected by Yahoo
> (andRuby) ==>s=open('http://download.finance.yahoo.com/d/quotes.csv?s=^DJI,^SPX,^IXIC&f=sl1d1t1nohgv&e...).read
> Is there a Ruby method that will automatically convert illegal
> characters into url-speak? Thanks, Bill

Oops, that url is ==> http://download.finance.yahoo.com/d/quotes.csv?s=%5eDJI,%5eSPX,%5eIXIC&f=sl1d1t1nohgv&...

Donald Ball

6/6/2008 8:06:00 PM

0

require 'cgi'

CGI.escape('^') => "%5E"

bsagert

6/6/2008 8:06:00 PM

0

On Jun 6, 1:00 pm, bsag...@gmail.com wrote:
> On Jun 6, 12:56 pm, bsag...@gmail.com wrote:
>
> > Hello, n00b here. I use open-uri to read a Yahoo .csv file of stock
> > and index quotes. Yahoo indices start with a circumflex ("^") which a
> > browser will convert to "%5e". The following line is rejected by Yahoo
> > (andRuby) ==>s=open('http://download.finance.yahoo.com/d/quotes.csv?s=^DJI,^SPX,^IXIC&f=sl1d1t1nohgv&e...).read
> > Is there a Ruby method that will automatically convert illegal
> > characters into url-speak? Thanks, Bill
>
> Oops, that url is ==>http://download.finance.yahoo.com/d/quotes.csv?s=%5eDJI,%5e......

Jeez, I really am a newbie. Of course the above link will work fine in
a browser.
The point is, it won't work in a Ruby script! The open-uri module
won't convert "^"
to "%5e" and the question is, is there a Ruby way?