Forum: Ruby View Source Code in Whois.net

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Chris B. (Guest)
on 2009-04-30 15:42
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?
Redd V. (Guest)
on 2009-04-30 16:51
(Received via mailing list)
gsub!(/>\s+</, '><') maybe?
Jack B. (Guest)
on 2009-04-30 18:50
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.
Mark T. (Guest)
on 2009-04-30 19:30
(Received via mailing list)
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.
Chris B. (Guest)
on 2009-04-30 22:33
Mark,

Please advise on libraries??  I am really trying to keep this really
simple.
7stud -. (Guest)
on 2009-05-01 00:57
Chris Berry wrote:
> Mark,
>
> Please advise on libraries??

hpricot, nokogiri, watir
This topic is locked and can not be replied to.