View Source Code in Whois.net

Discussion in 'Ruby' started by Chris Berry, Apr 30, 2009.

  1. Chris Berry

    Chris Berry Guest

    I am trying to view the source code in whois.net using the following
    code:


    require 'open-uri'
    open("http://whois.net/whois/qoxax.com") {|f|
    text = f.read
    lines = f.readlines
    text = lines.join
    text.gsub!(/\s+/," ")

    puts text

    }

    The whois.net view source has TONS of whitespace at the beginning and
    end which I am guessing is causing this to come up blank when I run this
    code but perhaps you have better ideas / luck?
    --
    Posted via http://www.ruby-forum.com/.
    Chris Berry, Apr 30, 2009
    #1
    1. Advertising

  2. [Note: parts of this message were removed to make it a legal post.]

    gsub!(/>\s+</, '><') maybe?

    On Thu, Apr 30, 2009 at 1:42 PM, Chris Berry <> wrote:

    > I am trying to view the source code in whois.net using the following
    > code:
    >
    >
    > require 'open-uri'
    > open("http://whois.net/whois/qoxax.com") {|f|
    > text = f.read
    > lines = f.readlines
    > text = lines.join
    > text.gsub!(/\s+/," ")
    >
    > puts text
    >
    > }
    >
    > The whois.net view source has TONS of whitespace at the beginning and
    > end which I am guessing is causing this to come up blank when I run this
    > code but perhaps you have better ideas / luck?
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >



    --
    http://www.home.no/reddvinylene
    Redd Vinylene, Apr 30, 2009
    #2
    1. Advertising

  3. Chris Berry

    Jack Bauer Guest

    Chris Berry wrote:
    > The whois.net view source has TONS of whitespace at the beginning and
    > end which I am guessing is causing this to come up blank when I run this
    > code but perhaps you have better ideas / luck?


    string.lstrip.rstrip will get rid of a lot of it.
    --
    Posted via http://www.ruby-forum.com/.
    Jack Bauer, Apr 30, 2009
    #3
  4. Chris Berry

    Mark Thomas Guest

    Why are you trying to view the source? You're not planning to parse
    HTML with regular expressions, are you? There are much better
    libraries out there for that.

    -- Mark.
    Mark Thomas, Apr 30, 2009
    #4
  5. Chris Berry

    7stud -- Guest

    7stud --, Apr 30, 2009
    #5
    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. NGLurker
    Replies:
    5
    Views:
    438
    Mark Rae
    Oct 17, 2004
  2. Parthiv Joshi
    Replies:
    1
    Views:
    659
    Samuel L Matzen
    Jul 6, 2004
  3. andspal

    Updates in Design view not moved to Source view

    andspal, Nov 2, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    177
    andspal
    Nov 2, 2006
  4. Jenny
    Replies:
    3
    Views:
    257
    Dag Sunde
    Dec 17, 2004
  5. Sylvain Robitaille

    Net-Whois-IP-0.35 returning incorrect responses?

    Sylvain Robitaille, Aug 6, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    185
    Sylvain Robitaille
    Aug 8, 2003
Loading...

Share This Page