Re: [wtr-general] How to get the status of http

2011-05-23 Thread Qiannan Zhang
Yes, it works , thank you very much

2011/5/23 Amit Bobade 

> Dear Qiannan,
>
> Here is the answer of you question. Use following code. This is working
> code. I used this in my scripts.
>
> require 'net/http'
> require 'uri'
>
> def page_status url
>   url = URI.parse(url)
>
>   http = Net::HTTP.new(url.host, url.port)
>
>   http.start do
> http.request_get(url.path.empty? ? "/" : url.path) do |res|
>   return {:name => res.class, :code => res.code}
> end
>   end
> end
>
> status = page_status("http://www.yourURL.com";)
>
> # Printing response class and status.
>
> puts res_class=status[:name]
> puts stat=status[:code]
>
>
>
> On Sat, May 21, 2011 at 9:25 PM, Qiannan Zhang wrote:
>
>> Hi, all
>> I need help, i do not know how to get the status of http, is there anyone
>> know how to do?
>> thanks
>>
>> --
>> Before posting, please read http://watir.com/support. In short: search
>> before you ask, be nice.
>>
>> watir-general@googlegroups.com
>> http://groups.google.com/group/watir-general
>> watir-general+unsubscr...@googlegroups.com
>>
>
>
>
> --
> Thanks and Regards,
> Amit
>
>  --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
>

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] How to get the status of http

2011-05-22 Thread Amit Bobade
Dear Qiannan,

Here is the answer of you question. Use following code. This is working
code. I used this in my scripts.

require 'net/http'
require 'uri'

def page_status url
  url = URI.parse(url)

  http = Net::HTTP.new(url.host, url.port)

  http.start do
http.request_get(url.path.empty? ? "/" : url.path) do |res|
  return {:name => res.class, :code => res.code}
end
  end
end

status = page_status("http://www.yourURL.com";)

# Printing response class and status.

puts res_class=status[:name]
puts stat=status[:code]



On Sat, May 21, 2011 at 9:25 PM, Qiannan Zhang  wrote:

> Hi, all
> I need help, i do not know how to get the status of http, is there anyone
> know how to do?
> thanks
>
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
>



-- 
Thanks and Regards,
Amit

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] How to get the status of http

2011-05-21 Thread Qiannan Zhang
Hi, all
I need help, i do not know how to get the status of http, is there anyone
know how to do?
thanks

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com