Why this web page stop my "open" action [open-uri]?

Discussion in 'Ruby' started by Tao Ji, Feb 4, 2010.

  1. Tao Ji

    Tao Ji Guest

    Hello,
    Need your help to find out what stop my "open" action. I'm using
    open-uri to get the webpages from http://quotes.163.com. When I try open
    other pages it works pefectly but spit out errors when I try to get the
    stock quote information.

    Can you give me some hints?

    Below is my sample code:
    ============================================
    require "open-uri"
    url_news = "http://news.163.com/10/0204/01/5UL33070000120GR.html" # a
    normal news page from 163.com
    url_600036 = "http://quotes.163.com/corp/1036/code=600036.html" # a
    stock info page from 163.com, this is problematic page
    url_blank = "http://news.163.com/10/0204/01/5UL22070000120GR.html" # a
    request to a nonexisted page
    #response = open(url_news) # I can go smoothly
    #response = open(url_blank) # also no error
    response = open(url_600036) # Yes error comes here
    puts "Character set is #{response.charset}"
    puts "Size is #{response.size}"
    ===============================================
    --
    Posted via http://www.ruby-forum.com/.
     
    Tao Ji, Feb 4, 2010
    #1
    1. Advertising

  2. Tao Ji

    pharrington Guest

    On Feb 3, 10:50 pm, Tao Ji <> wrote:
    > Hello,
    > Need your help to find out what stop my "open" action. I'm using
    > open-uri to get the webpages fromhttp://quotes.163.com. When I try open
    > other pages it works pefectly but spit out errors when I try to get the
    > stock quote information.
    >
    > Can you give me some hints?
    >
    > Below is my sample code:
    > ============================================
    > require "open-uri"
    > url_news = "http://news.163.com/10/0204/01/5UL33070000120GR.html" # a
    > normal news page from 163.com
    > url_600036 = "http://quotes.163.com/corp/1036/code=600036.html" # a
    > stock info page from 163.com, this is problematic page
    > url_blank = "http://news.163.com/10/0204/01/5UL22070000120GR.html" # a
    > request to a nonexisted page
    > #response = open(url_news) # I can go smoothly
    > #response = open(url_blank) # also no error
    > response = open(url_600036) # Yes error comes here
    > puts "Character set is #{response.charset}"
    > puts "Size is #{response.size}"
    > ===============================================
    > --
    > Posted viahttp://www.ruby-forum.com/.


    Is the error you're getting "SocketError: getaddrinfo: Name or service
    not known"?

    If not, copy and paste the full error.
     
    pharrington, Feb 4, 2010
    #2
    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,389
    Simon Harris
    May 10, 2005
  2. Stanimir Stamenkov
    Replies:
    1
    Views:
    2,479
    Stanimir Stamenkov
    Aug 17, 2005
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,030
    Smokey Grindel
    Dec 2, 2006
  4. Jay 99
    Replies:
    2
    Views:
    193
    Jay 99
    Apr 4, 2009
  5. Turbo
    Replies:
    2
    Views:
    162
    Turbo
    Nov 1, 2006
Loading...

Share This Page