Giter Site home page Giter Site logo

kevinmartintk / news_fetcher Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 15 KB

A simple news fetch gem that returns data and prints it in a fancy color. Basic web scrapping.

Home Page: https://rubygems.org/gems/news_fetcher

License: MIT License

Ruby 100.00%

news_fetcher's Introduction

Badge

News Fetcher

News Fetcher is a simple gem that uses Nokogiri for parsing HTML documents fetched from the Internet and returns selected data that can be printed out to Unix STDOUT in a variety of colors like so:

Image

or

Image

Installation

$ gem install news_fetcher

or directly in your Gemfile

gem 'news_fetcher'

Usage

News Fetcher uses the OpenURI Ruby module to get the HTML content of a webpage and Nokogiri to parse the response given a structure (e.g. XPath). Use the fetch method to get the information you want from a certain url, also specifying the xPath you are looking for and the color you want to see your results (terminal only):

document, nodes = NewsFetcher.fetch('https://techcrunch.com', 'h2/a', 'orange')

document ### The Nokogiri HTML Document object
nodes ### The matching nodes found in the document

Available colors are:

  • Black
  • Red
  • Green
  • Orange
  • Blue
  • Purple
  • Cyan
  • Gray

If you don't specify the color it will take black by default

News Fetcher also provides a CLI so you can call it from your favorite terminal and see the results:

nf fetch http://www.bbc.com/ div/h3/a blue

or

news_fetcher fetch http://edition.cnn.com/tech div/h3/a/span red

MIT License

  • Copyright (c) 2016 Kevin Martin. See LICENSE.txt for details.

news_fetcher's People

Contributors

kevinmartintk avatar inobtenio avatar

Watchers

James Cloos avatar  avatar

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.