Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Count of http requests
jfry
10/2/2007 11:44:00 PM
Using the YSlow Firebug extension
http://developer.yahoo....
,
I can see how many HTTP requests a page made. For example,
http://slashdot.org/po...
shows:
This page has 7 external JavaScript files.
This page has 5 external StyleSheets.
This page has 18 CSS background images.
I'm wondering how I can use Net::HTTP (and or other Ruby libs) to
capture this information. I'm starting with a script that can tell me
the header info and size of the page (below):
require 'net/http'
a = String.new
r = String.new
Net::HTTP.start('slashdot.org') do |http|
response = http.get('/pollBooth.pl')
puts "Code = #{response.code}"
puts "Message = #{response.message}"
response.each {|key, val| printf "%-14s = %-40.40s\n", key, val }
a = response.body
r = response
end
body_io = StringIO.new(r.body)
unzipped_body = body_io.read()
puts "Count of characters in page = #{unzipped_body.size}"
Thanks!
Jeff Fry
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Count of http requests
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password