From: Robert Klemme Date: 2012-12-08T18:58:50+09:00 Subject: Re: Parsing json which require username and password On Sat, Dec 8, 2012 at 9:47 AM, Ferdous ara wrote: > Hi > I want Fetch a web page which has json output, but the problem is, that > page has username and password, so i am using like this > > #!/usr/bin/ruby > require 'rubygems' > require 'json' > > > > current=`curl -fs -basic -u "username:password" > http://ourmonitoringsystem.lan/cgi-bin/status.cgi?serviceprops=42&servicestatustypes=28&type=detail&hostprops=10&host=all&page=1&entries=all&view_mode=json` > > result=JSON.parse(current) > > puts result > > > But ts its giving me data + html output .. > > what will be the best way to achive my goal ? If the request returns HTML you need a HTML parser and not a JSON parser. -> Nokogiri Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/