# HTML extraction using ruby

**URL:** <https://rubytalk.org/t/html-extraction-using-ruby/52261>\
**Category:** ruby-talk\
**Created:** [13 March 2009 05:29 UTC](https://rubytalk.org/t/html-extraction-using-ruby/52261 "2009-03-13T05:29:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arun\_Kumar2](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@Arun\_Kumar2](https://rubytalk.org/u/Arun_Kumar2)\
**Post date:** [13 March 2009 05:29 UTC](https://rubytalk.org/t/html-extraction-using-ruby/52261/1 "2009-03-13T05:29:42Z")

</div>

Hi,  
Can anybody tell me how to extract all the hyperlinks given in the  
url:[http://scores.sify.com/match/archive/archive.shtml](http://scores.sify.com/match/archive/archive.shtml) using ruby. I  
want the those urls having the class 'com\_blue com\_size12 com\_arial12'.  
ie. to be more precise  
\<a class="com\_blue com\_size12 com\_arial12" href=""\>, these are the type  
of urls i want to have.  
Please help. I'll be really greatfull.

Regards,  
Arun Kumar .C.M.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Phlip1](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@Phlip1](https://rubytalk.org/u/Phlip1)\
**Post date:** [13 March 2009 14:32 UTC](https://rubytalk.org/t/html-extraction-using-ruby/52261/2 "2009-03-13T14:32:56Z")

</div>

Arun Kumar wrote:

> Hi,  
> Can anybody tell me how to extract all the hyperlinks given in the  
> url:[http://scores.sify.com/match/archive/archive.shtml](http://scores.sify.com/match/archive/archive.shtml) using ruby. I  
> want the those urls having the class 'com\_blue com\_size12 com\_arial12'.  
> ie. to be more precise  
> \<a class="com\_blue com\_size12 com\_arial12" href=""\>, these are the type  
> of urls i want to have.

Use doc = Nokogiri::HTML( my\_html ), then something like doc.css('a.com\_blue').each

---

<div class="post-metadata">

**Author:** ![Arun\_Kumar2](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@Arun\_Kumar2](https://rubytalk.org/u/Arun_Kumar2)\
**Post date:** [14 March 2009 03:41 UTC](https://rubytalk.org/t/html-extraction-using-ruby/52261/3 "2009-03-14T03:41:17Z")

</div>

Phlip wrote:

> Arun Kumar wrote:
> 
> > Hi,  
> > Can anybody tell me how to extract all the hyperlinks given in the  
> > url:[http://scores.sify.com/match/archive/archive.shtml](http://scores.sify.com/match/archive/archive.shtml) using ruby. I  
> > want the those urls having the class 'com\_blue com\_size12 com\_arial12'.  
> > ie. to be more precise  
> > \<a class="com\_blue com\_size12 com\_arial12" href=""\>, these are the type  
> > of urls i want to have.
> 
> Use doc = Nokogiri::HTML( my\_html ), then something like  
> doc.css('a.com\_blue').each

Sorry that doesn't work. Showing an error like this.

uninitialized constant Nokogiri (NameError)

Regards  
Arun Kumar

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Phlip1](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@Phlip1](https://rubytalk.org/u/Phlip1)\
**Post date:** [14 March 2009 04:17 UTC](https://rubytalk.org/t/html-extraction-using-ruby/52261/4 "2009-03-14T04:17:50Z")

</div>

Arun Kumar wrote:

> Sorry that doesn't work. Showing an error like this.
> 
> uninitialized constant Nokogiri (NameError)

You are going to need to learn more Ruby before asking high-level questions about it.

What did Google tell you about Nokogiri, or RubyGems?
