Flatiron School: cli-stock-information

Samuel DeSantis
2 min readJan 28, 2021

Summary: Provides information for the specified stock symbol(s).

Github: https://github.com/Samuel-DeSantis/cli-stock-information

Google Finance

Google Finance offers great key statistics that are easily accessible for web scraping programs. Using its simple URL formatting it’s possible to search for essentially any stock supported on Google Finance. As long as the user enters in an existing stock symbol and the programs stock market list contains the appropriate market, as seen below, the program should be able to retrieve the key statistics for the specified stock(s).

Fig. 1: Stock Market List

Nokogiri works extremely well to scrape, then isolate the key stats for the specified stock symbol. Once the key stats have been isolated the information is stored in a hash so it can be passed easily to a Stock object. Check out the Google Finance link below.

Stock Objects

The stock object simply stores the information scraped from Google Finance to make it easy to access and display the data that has been gathered. The stock object creates a Google Finance object to search for the specific symbol, then the stock object manipulates the returned hash so that it is more readable for the user when accessed through the CLI.

CLI Setup

The CLI begins with a simple introduction of how to use the program and the format that the input should be submitted as. Once the user submits their stock(s), they are then shown the specified stock data that they requested to look up. Once the data of each stock is displayed, then the user must decide whether they want to look up more stock symbols or whether they are finished and wish to exit the program. If the user wishes to look up more symbols, then the user is looped back to the beginning of the program to enter more symbols. If the user is finished and doesn’t want to look up any more symbols, then they can exit the program.

--

--