Hi! I rarely code but when I try I use Ruby. So this is a beginners problem :) Im trying to fetch a number from a website and im using mechanize but it seems to be impossible. Im doing this: require 'Mechanize' agent = Mechanize.new agent.get("http://www.linasmatkasse.se") agent.page.search('#counter') This div should contain a value but it doesnt. I get this in irb: [#<Nokogiri::XML::Element:0x83fe5ff0 name="div" attributes=[#<Nokogiri::XML::Attr:0x83fde2b4 name="id" value="counter">]>] This div contains a number like 26 100 002 when looking at the website. What is it that im doing wrong? Any suggestion is appreciated! :) Br cristian
on 2012-12-11 23:59
on 2012-12-12 07:16
On Tue, Dec 11, 2012 at 5:00 PM, cristian cristian <email@example.com> wrote: > agent.page.search('#counter') > > Any suggestion is appreciated! :) > > Br > cristian > > -- > Posted via http://www.ruby-forum.com/. > When you just load the html, that div is empty: <div id="counter"></div> One of the scripts on that page is filling it in.
on 2012-12-12 08:09
on 2012-12-12 18:27
Thank you both! Now I understand why my code didnt work and I solved my problem! Br cristian