# How to collect all the href links in a single page to a log file

**URL:** <https://www.ruby-forum.com/t/how-to-collect-all-the-href-links-in-a-single-page-to-a-log-file/153081>\
**Category:** Ruby\
**Created:** [November 11, 2008, 10:39pm UTC](https://www.ruby-forum.com/t/how-to-collect-all-the-href-links-in-a-single-page-to-a-log-file/153081 "2008-11-11T22:39:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sita\_Rami\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Sita\_Rami\_R](https://www.ruby-forum.com/u/Sita_Rami_R)\
**Post date:** [November 11, 2008, 10:39pm UTC](https://www.ruby-forum.com/t/how-to-collect-all-the-href-links-in-a-single-page-to-a-log-file/153081/1 "2008-11-11T22:39:59Z")

</div>

I have a web which consists of multiple links with different colors. I  
want  
to collect a set of links with same color and move them to a notepad  
file(log file)…

Please give Ruby code which works in Watir.

Thanks,

---

<div class="post-metadata">

**Author:** ![Sita\_Rami\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Sita\_Rami\_R](https://www.ruby-forum.com/u/Sita_Rami_R)\
**Post date:** [November 12, 2008, 5:19am UTC](https://www.ruby-forum.com/t/how-to-collect-all-the-href-links-in-a-single-page-to-a-log-file/153081/2 "2008-11-12T05:19:23Z")

</div>

for colors do you applied any css?  
if so, u can take through class name.

---

<div class="post-metadata">

**Author:** ![Sita\_Rami\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Sita\_Rami\_R](https://www.ruby-forum.com/u/Sita_Rami_R)\
**Post date:** [November 12, 2008, 7:08am UTC](https://www.ruby-forum.com/t/how-to-collect-all-the-href-links-in-a-single-page-to-a-log-file/153081/3 "2008-11-12T07:08:05Z")

</div>

My actual problem is as follows:

Â· Navigate to Google in a new IE instance  
Â· Search for the following word “Gap, Inc.”  
Â· Iterate thought the first 10 pages of google  
Â· On each page collect the following  
Â· The “blue” page title  
Â· The “green” url  
Â· Output all the data into a file named “test\_output.txt”  
Â· Format "Title â€“ URL

Can you help me in this…

Thanks,  
Sita

On Tue, Nov 11, 2008 at 8:16 PM, Srinivasa R.  
\<removed\_email\_address@domain.invalid
