Michael Jerome
2008-Feb-15 09:26 UTC
[Mechanize-users] Performance - can anyone suggest why this is slow?
Hello All This is my first post to mechanize-users at rubyforge.org so be gentle! Please take a look at the code and output below. The code uses Mechanize to load two web pages; the output shows the time before and after loading each page. Both pages load successfully but while http://www.google.com takes less than a second, http://tinyurl.com/7pqpx is taking about THREE MINUTES!!! I realise that the second page is "heavier" than the first and I realise there are HTTP and META redirects but something isn''t right if it''s taking three minutes ... Firefox loads http://tinyurl.com/7pqpx in seconds. Can anyone suggest what''s causing it to be so slow? Is it possible the site is detecting I''m using Mechanize and slowing it down intentionally? Any help or advice is really appreciated. Regards Mike ################# This code: ["http://www.google.com", "http://tinyurl.com/7pqpx"].each do |url| agent = WWW::Mechanize.new agent.user_agent_alias = ''Windows IE 7'' agent.follow_meta_refresh = true puts "Started getting #{url} at #{Time.now}" page = agent.get( url ) puts "Completed getting #{url} at #{Time.now}" end ################# Gives this output: Started getting http://www.google.com at Fri Feb 15 09:10:15 Completed getting http://www.google.com at Fri Feb 15 09:10:15 Started getting http://tinyurl.com/7pqpx at Fri Feb 15 09:10:15 Completed getting http://tinyurl.com/7pqpx at Fri Feb 15 09:13:16 #################