Git Product home page Git Product logo

guts's Introduction

Guts

The Guts gem allows you to extract content and metadata from a given news article in HTML.

This gem is in an extremely experimental state right now

Examples

The Document object is constructed with the HTML text from the page we're parsing. The url and site name can optionally be passed in as metadata to provide more accurate parsing.

# simplest use-case
page = Guts::Document.new(html_text)

# optionally pass in the url and site name
url  = http://online.wsj.com/article/SB10001424127887323975004578501134104800170.html
name = "The Wall Street Journal"
page = Guts::Document.new(html_text, :url => url, :site_name => name)

page.headline
=> "Rivera's So-Called Retirement"

page.author
=> "Jason Gay"

page.date
=> Thu, 23 May 2013 21:10:00 EDT -04:00

page.images
=> [#<Guts::Image:0x007fa905c58c20>]

page.content
=> "Dear Mariano Rivera,\n\nWhoa, whoa, whoa. Slow down. You're amazing, Mo. But take it easy. You're making everyone else look terrible.\n\nLook: All of baseball thought it was a good idea for you to come back. OK, that's not totally true. People were worried."

page.formatted_content
=> "<h1>Rivera's So-Called Retirement</h1><p>Dear Mariano Rivera,</p><p>Whoa, whoa, whoa. Slow down. You're amazing, Mo. But take it easy. You're making everyone else look terrible.</p><p>Look: All of baseball thought it was a good idea for you to come back. OK, that's not totally true. People were worried.</p> "

page.summary
=> "Dear Mariano Rivera, Whoa, whoa, whoa. Slow down. You're amazing, Mo. But take it easy. You're making everyone else look terrible."

Installation

To install Guts, add the gem to your Gemfile:

gem "guts"

LICENSE

Copyright (c) 2013 Derek DeVries

Released under the MIT License

guts's People

Contributors

devrieda avatar

Watchers

 avatar

Forkers

hazemusa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.