# Re: Posix Pangrams (#97)

**URL:** <https://www.ruby-forum.com/t/re-posix-pangrams-97/71298>\
**Category:** Ruby\
**Created:** [October 6, 2006, 7:08pm UTC](https://www.ruby-forum.com/t/re-posix-pangrams-97/71298 "2006-10-06T19:08:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 6, 2006, 7:08pm UTC](https://www.ruby-forum.com/t/re-posix-pangrams-97/71298/1 "2006-10-06T19:08:44Z")

</div>

From: Jamie M. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

> > (There’s no joy in trying to parse/string HTML.)  
> > Sure there is.
> 
> require ‘rubygems’; require ‘hpricot’; require ‘open-uri’  
> doc = Hpricot(open(‘[http://www.unix.org/version3/apis/cu.html](http://www.unix.org/version3/apis/cu.html)’))  
> puts (doc/“p.tent/i”).map{|i|i.inner\_html}
> 
> Hpricot makes HTML scraping fun again (no, really!).

🙂

I copy/pasted the rows from the table and did it like this:  
puts \<\<ENDS.scan( /_([^\<]+)/ ).flatten.join( ’ ’ )  
 #HTML HERE  
ENDS_

 

Actually…I can’t get Hpricot to install to test your code (gem server  
seems to be down) but doesn’t that grab way more information than you  
wanted from the table? The table headers and all columns, too?

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 6, 2006, 7:41pm UTC](https://www.ruby-forum.com/t/re-posix-pangrams-97/71298/2 "2006-10-06T19:41:12Z")

</div>

On 10/6/06, Gavin K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> From: Jamie M. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]
> 
> > require ‘rubygems’; require ‘hpricot’; require ‘open-uri’  
> > doc = Hpricot(open(‘[http://www.unix.org/version3/apis/cu.html](http://www.unix.org/version3/apis/cu.html)’))  
> > puts (doc/“p.tent/i”).map{|i|i.inner\_html}
> 
> Actually…I can’t get Hpricot to install to test your code (gem server  
> seems to be down) but doesn’t that grab way more information than you  
> wanted from the table? The table headers and all columns, too?

I’m assuming the problems with the gem server are related to the  
problems with RubyForge. Hopefully that will be resolved soon, I know  
it’s being worked on.

Regarding your question: note the “/i” after “p.tent”.

Jacob F.

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 6, 2006, 7:47pm UTC](https://www.ruby-forum.com/t/re-posix-pangrams-97/71298/3 "2006-10-06T19:47:12Z")

</div>

On 10/6/06, Gavin K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> From: Jamie M. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]
> 
> > require ‘rubygems’; require ‘hpricot’; require ‘open-uri’  
> > doc = Hpricot(open(‘[http://www.unix.org/version3/apis/cu.html](http://www.unix.org/version3/apis/cu.html)’))  
> > puts (doc/“p.tent/i”).map{|i|i.inner\_html}
> 
> Actually…I can’t get Hpricot to install to test your code (gem server  
> seems to be down) but doesn’t that grab way more information than you  
> wanted from the table? The table headers and all columns, too?

I am pulling the entire html file down, but by dividing the Hpricot  
instance I’m essentially asking it to give me all the _tags that  
are inside a_

_with the tent class. Given the content of the file I  
could probably just do doc/“i” but it would also grab the ‘opt’ from  
the definition list up top._

 

My code does give the same output as yours, excepting that since I’m  
putsing the array rather than joining I get one command per line.

- Jamie
