On Sat, Dec 8, 2012 at 9:47 AM, Ferdous ara <[email protected]> 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/

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to