From: Aaron Barwell Date: 2010-05-14T22:32:26+09:00 Subject: using Ruby to extract search result Hi I am a complete beginner (used ruby for the first time today). I can't seem to distinguish between Google's sponsored links and other search results I want to be be able to search for aprt of a url to see if it appears in the 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 anytone knows the way to solve this or at least a pointer I seem to be able to indentify spored links if the search term appears in them. # # Outputs: Each step of test # Page found on google (if found) # URL of the link clicked # Load time of page (assuming successful load # # Watir controller require "watir" Watir::Browser.default = "firefox" # Website used test_site = "http://www.google.co.uk" # Search term, search_term = [I specify a search term here] #open up Firefox browser = Watir::Browser.start test_site # Open google.co.uk puts "Step 1: Opening:" + test_site browser.goto test_site # search term as set up puts " Step 2: Searching for phrase '"+search_term+"' " browser.text_field(:name, "q").set ""+search_term # Google's search field #click the google search button puts " Step 3: click the search button." browser.button(:name, "btnG").click # Click button # 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 -- Posted via http://www.ruby-forum.com/.