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

On Saturday, June 20, 2015 at 12:05:04 PM UTC-4, Elizabeth McGurty wrote:
>
> 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.   
>
>
> On Saturday, June 20, 2015 at 11:02:45 AM UTC-4, Edsil Basadre wrote:
>>
>> 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 <emcg...@gmail.com> 
>> wrote:
>>
>>> 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-ta...@googlegroups.com.
>>> To post to this group, send email to rubyonra...@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
>>>  
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/ad85e60c-b26c-4ea4-bcff-c90919f4ac89%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
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/b71fdce0-9271-4d19-92cd-df22b647177a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to