How can I get number of AdWords Advertiser in top and right side position in Google search result

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?

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:

Followed by a ordered list of the ads:
  1. 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

From top … I don’t think that it matters. You just have to use
Nokogiri/JQuery/CSS to find the AdWord element in the HTML. Just code
for
the exception that it is not there.

By the way, Edsil, I think that I may have been too quick responding to
your apparent requirement for top and right side position.

Ideally one would hope that you could identify the document element of
interest, and run a JQuery-like request for .position(). Then compare
the
left/right results to surmise the most likely in the top and right in
the
document. I have since learned in posting a question to Google Group
nokogiri-talk that Nokogiri does not provide that level of JQuery-like
results. So I asked the question:

“So finding position is out of the question. What I am interested in
learning is this: A particular web page arbitrarily and randomly
provides/places a certain div. I can identify that div, but I am just
not
sure where it is located in the entirety of the document. What methods
do
you suggest as most helpful… I can work with even sort of vague or
uncertain suggestions.”

And a person there, sorry I don’t have permission to identify him,
responded with:

“You may want to try using the “.path” method if you’ve found a
particular
Node, which will basically tell you where in the XML document tree that
Node is. Specifically, it returns the XPath query string which you can
read
more about if you Google “w3c xpath”.”

Hope this helps

Liz

Hi Elizabeth,

Thank you for this, it really helps to me. But one thing I am confused
how
canI check if the adWork is from top position and right position.

Thanks you so much liz.

On Sat, Jun 20, 2015 at 7:42 PM, Elizabeth McGurty [email protected]

BTW, regarding: “And a person there, sorry I don’t have permission to
identify him” I am not saying that the author refused permission, I am
saying that I did not seek it. Generally my statement is that I am not
taking credit for the suggestion.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs