open-uri and illegal url characters

Discussion in 'Ruby' started by bsagert@gmail.com, Jun 6, 2008.

  1. Guest

    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=.csv').read
    Is there a Ruby method that will automatically convert illegal
    characters into url-speak? Thanks, Bill
     
    , Jun 6, 2008
    #1
    1. Advertising

  2. Guest

    On Jun 6, 12:56 pm, 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=.csv').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=^DJI,^SPX,^IXIC&f=sl1d1t1nohgv&e=.csv
     
    , Jun 6, 2008
    #2
    1. Advertising

  3. Donald Ball Guest

    require 'cgi'

    CGI.escape('^') => "%5E"
     
    Donald Ball, Jun 6, 2008
    #3
  4. Guest

    On Jun 6, 1:00 pm, wrote:
    > On Jun 6, 12:56 pm, 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=.csv').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=^DJI,^SPX,^IXI...


    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?
     
    , Jun 6, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Harris
    Replies:
    0
    Views:
    6,489
    Simon Harris
    May 10, 2005
  2. Stanimir Stamenkov
    Replies:
    1
    Views:
    2,538
    Stanimir Stamenkov
    Aug 17, 2005
  3. Fernie
    Replies:
    10
    Views:
    5,969
    Jukka K. Korpela
    Dec 21, 2004
  4. Jay 99
    Replies:
    2
    Views:
    216
    Jay 99
    Apr 4, 2009
  5. Turbo
    Replies:
    2
    Views:
    182
    Turbo
    Nov 1, 2006
Loading...

Share This Page