Hello, If I understand correctly, you're looking for the search term to be in the result link's URL, correct?
If so, you can use this: browser = Watir::IE.start('http://www.google.com') browser.text_field(:name, 'q').set 'watir' browser.button(:name, 'btnG').click browser.links.each do |link| if link.class_name == 'l' if link.href =~ /watir/i puts link.text end end end On May 17, 3:59 am, ambarw <aaronbarw...@googlemail.com> wrote: > I am new to Watir and Ruby and have ben trying to esablish a reliable > way of extracting the search result from a google search. > I can't seem to distinguish between Google's sponsored links and other > search results > I want to be be able to search for pat of a url to see if it appears > in he googles search result on a page but not in the sponsored links > I thought about trying to use class along with url in browser.link > because I notice google has a class of 'l' for normal listings but > this > doesn't work. > I will incorporate it into a while loop to search the first few pages. > I will be grateful if anyone knows the way to solve this or at least a > pointer.Iseem to be able to indentify spored links if the search term > appears > in them. > > The following fails to detect anything withing the listed (non- > sponsored) results > # Attempt to select the non sponsored link by selecting class l > (fails), > and url attribute > url_existing = (browser.link(:url, /[searchterm]/).exists?) > .... (within a loop) > if url_existing == true # If URL is found > > -- > Before posting, please readhttp://watir.com/support. In short: search before > you ask, be nice. > > You received this message because you are subscribed > tohttp://groups.google.com/group/watir-general > To post: watir-general@googlegroups.com > To unsubscribe: watir-general+unsubscr...@googlegroups.com -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. You received this message because you are subscribed to http://groups.google.com/group/watir-general To post: watir-general@googlegroups.com To unsubscribe: watir-general+unsubscr...@googlegroups.com