views:

37

answers:

1

Can anyone recommend a Ruby library for creating a summary of a given URL? What I have in mind is the sort of one- or two-sentence summary as seen in search engine results.

+1  A: 

You could you just scrape the web page for either description meta tag or if that's not available the first few sentences from the first <p> element on the page. The description meta tag looks like this:

<meta name="description" content="Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser with XPath and CSS selector support." />

There's several Ruby libraries for parsing HTML. I hear that Nokogiri is good for this sort of stuff, but I have no experience with it personally.

Mark A. Nicolosi
That sounds like a good strategy for a first stab. And I've used Nokogiri a number of times in the past; it is my lib of choice for webscraping. Thanks for your response, Mark.
Pistos