Once you load the Google results, presumably by some Nokogiri call like:

Nokogiri::HTML(open...) the html will be stored to some (XML?) source, 
let's call it google_results_doc.

Then you need to use Nokogiri css methods to locate your AdWord html.

First you need to take a look at Source Code underlying the google 
results.  Seems to  me that all AdWords are stored in a beginning div:

<div id="tads" class="_Ak c" ..>
Followed by a ordered list of the ads:
<ol>
<li class="ads-ad" ...>

seems to me that you could just write:

my_ad_count = google_results_doc.css(".ads-ad").length
or
my_ad_count = google_results_doc.css(".ads-ad").size

to get your count.  I write this assuming that Google is consistent in 
always using class name "ads-ad".  You may need to code to find it first, 
if not perhaps search for the yellow Ad icon.

Not sure which
Check out:

http://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/DocumentFragment#css-instance_method

for a listing of navigation/selector methods.

There is a tool called SelectorGadget that can help you identity selectors 
on html

Hope this helps..
Liz

On Saturday, June 20, 2015 at 5:49:29 AM UTC-4, Edsil Basadre wrote:
>
> I'm trying to build a simple application in rails that getting all search 
> result in google and count the number of AdWords advertiser in top and 
> right side position. I already get all the query result using Nokogiri but 
> I don't know how can I get the number of AdWords advertiser. 
>
> Is there any gems, tools or api how can I get number of AdWords? 
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/ad85e60c-b26c-4ea4-bcff-c90919f4ac89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to