I'm currently looking at Mechanize. I am new to Ruby, so please be patient.
I wrote a small test script:
require 'rubygems' require 'mechanize' agent = WWW::Mechanize.new page = agent.get('http://www.google.de') pp page.title google_form = page.form_with(:name => 'f') google_form.q = 'test' page = agent.submit(google_form) pp page.title page_links = Array.new page.links.each do |ll| page_links << ll end puts page_links.size
It works. But page_links includes more than just search results. It also includes google links such as Login, Pictures, ... As a result, the links have a class “1” style. Is it possible to select only links with class == 1? How to achieve this?
Is it possible to change the "agration"? If I have a website, including Google analytics or something like that, which browser will I see in ga coming with mechanization on my website?
Can I select elements by their identifier instead of name? I tried to use
my_form = page.form_with(:id => 'myformid')
But that will not work.
source share