Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > View Source Code in Whois.net

Reply
Thread Tools

View Source Code in Whois.net

 
 
Chris Berry
Guest
Posts: n/a
 
      04-30-2009
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/.

 
Reply With Quote
 
 
 
 
Redd Vinylene
Guest
Posts: n/a
 
      04-30-2009
[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 <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
 
Jack Bauer
Guest
Posts: n/a
 
      04-30-2009
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/.

 
Reply With Quote
 
Mark Thomas
Guest
Posts: n/a
 
      04-30-2009
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.
 
Reply With Quote
 
7stud --
Guest
Posts: n/a
 
      04-30-2009
Chris Berry wrote:
> Mark,
>
> Please advise on libraries??


hpricot, nokogiri, watir

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updates in Design view not moved to Source view andspal ASP .Net Web Controls 0 11-02-2006 08:13 AM
how do i edit source (like in IE, view..source)? q_q_anonymous@yahoo.co.uk Firefox 4 05-13-2006 11:07 PM
can't use View, Source menu to open the source code. Jenny Javascript 3 12-17-2004 07:01 AM
How to make a week view and day view calendar just like month view calendar in .NET ? Parthiv Joshi ASP .Net Web Controls 1 07-06-2004 03:15 PM
Can't View Source code? David H HTML 27 11-28-2003 10:57 AM



Advertisments