J
jfry
Using the YSlow Firebug extension http://developer.yahoo.com/yslow/ ,
I can see how many HTTP requests a page made. For example,
http://slashdot.org/pollBooth.pl 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
I can see how many HTTP requests a page made. For example,
http://slashdot.org/pollBooth.pl 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