Ruby - Mechanize: Select link by classname and other questions -


I'm currently looking at a mechanical gadget. I am very new to Ruby, please be patient.

I have written a small test:

  'rubygems' is required 'mechanize' agent = WWW :: mechanize. New page = agent.get ('http://www.google.de') pp page.title google_form = page.form_with (: name = & gt; 'f') google_form.q = 'test' page = agent Submit (google_form) pp page.title page_links = Array.new page.links.each do | Ll Page_Link & lt; & Lt; Ll finally puts page_link. Size  

This works but not only the search results in Page_Link , including log in, pictures, Google links like ... result one The relation is with the stylus "1". Is it possible to select only links with class == 1? How do I get it?

Is it possible to modify "Agentius"? If I'm the owner of a website, which includes Google Analytics or something, then on which site will I be able to see the GALActor with mechanized?

Can I select elements instead of my ID? Tried using

  my_form = page.form_with (: id = & gt; 'myformid')  

but it does not work.

You can simply create a list of search result links by changing your code:

  page.links.each do | Ll CLS = ll.attributes.attributes ['class'] page_links & lt; & Lt; If CLS & amp; Amp; For each element's  ll  in  page.links ,  ll.attributes   

cls.value = = 'L' end

/ code> a notchyri :: XML :: alignment and ll.attributes.attributes a Hash , which has the attributes on the link, so to compare the actual class and value for ll.attributes.attributes 'L'

Before comparing the need for zero check, the : id is the criteria to find a form that is in the form of Rs. To return the internal ID of the object, there is a conflict with Ruby's object # id method, I'm not sure what the work is for it, by the form of any other attribute (such as its verb). There will be no problem in choosing


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -