F
Francis Hwang
Hi all,
I've just released the first version of HtmlClipping.
== What's HtmlClipping?
HtmlClipping is a library for reading an HTML page that has a link
pointing to a particular URI. It removes most HTML markup, bolds the
link text, and trims the resulting text to a fixed number of
characters. I developed it to help me track referers to my website,
though I suppose it might have other uses.
For example, the following script gets the HTML at
rubyforge.org/credits/, and forms an excerpt around the link to
www.rubycentral.org/pledge/.
require 'htmlclipping'
require 'net/http'
contents = ''
Net::HTTP.start( 'rubyforge.org' ) do |http|
response = http.get '/credits/'
contents = response.body
end
clipping = HtmlClipping.new(
contents, 'http://www.rubycentral.org/pledge/', 500
)
puts clipping.to_s
=> "… RubyForge takes time, effort, and money. Many thanks to
the
folks listed below who are making it possible! <br /> If RubyForge
has
been helpful to you, and you want to give something back to the
Ruby
community, please consider supporting <strong>RubyCentral</strong>.
Thanks! <br /> InfoEther, Inc purchased the RubyForge hardware and
provides system administration support. <br /> Several folks
provide
file mirrors to help share the bandwidth load: <br /> Evan Webb
<br />
Dennis Oelkers <br /> Austin …"
http://rubyforge.org/projects/htmlclipping
Francis Hwang
http://fhwang.net/
I've just released the first version of HtmlClipping.
== What's HtmlClipping?
HtmlClipping is a library for reading an HTML page that has a link
pointing to a particular URI. It removes most HTML markup, bolds the
link text, and trims the resulting text to a fixed number of
characters. I developed it to help me track referers to my website,
though I suppose it might have other uses.
For example, the following script gets the HTML at
rubyforge.org/credits/, and forms an excerpt around the link to
www.rubycentral.org/pledge/.
require 'htmlclipping'
require 'net/http'
contents = ''
Net::HTTP.start( 'rubyforge.org' ) do |http|
response = http.get '/credits/'
contents = response.body
end
clipping = HtmlClipping.new(
contents, 'http://www.rubycentral.org/pledge/', 500
)
puts clipping.to_s
=> "… RubyForge takes time, effort, and money. Many thanks to
the
folks listed below who are making it possible! <br /> If RubyForge
has
been helpful to you, and you want to give something back to the
Ruby
community, please consider supporting <strong>RubyCentral</strong>.
Thanks! <br /> InfoEther, Inc purchased the RubyForge hardware and
provides system administration support. <br /> Several folks
provide
file mirrors to help share the bandwidth load: <br /> Evan Webb
<br />
Dennis Oelkers <br /> Austin …"
http://rubyforge.org/projects/htmlclipping
Francis Hwang
http://fhwang.net/