[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

View Source Code in Whois.net

Chris Berry

4/30/2009 11:43:00 AM

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


require 'open-uri'
open("http://whois.net/whois/qoxax...) {|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-....

5 Answers

Redd Vinylene

4/30/2009 12:50:00 PM

0

[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 <c_berry@mac.com> 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...) {|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-....
>
>


--
http://www.home.no/re...

Jack Bauer

4/30/2009 2:51:00 PM

0

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-....

Mark Thomas

4/30/2009 3:29:00 PM

0

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.

7stud --

4/30/2009 8:58:00 PM

0

Chris Berry wrote:
> Mark,
>
> Please advise on libraries??

hpricot, nokogiri, watir

--
Posted via http://www.ruby-....