DEV Community

andreanasuto
andreanasuto

Posted on

3 1

Building a Ruby gem with CLI that scrapes data from an online page

I've been completing my software development bootcamp in full-stack web development at Flatiron School (now part of the WeWork galaxy).

As the first portfolio project, I am required to developed a command-in-line application.

The task for CLI Project is to build a Ruby gem that provides a Command Line Interface (CLI) to an external data source. The CLI will be composed of an Object Oriented Ruby application.
I could scrape information from any webpage I liked: weather forecasting page, news page, anything sport related. Based on that information I created my own program. I picked the Transfermkt website (https://www.transfermarkt.com/), I scraped updated information on my favorite soccer league (or football, it depends on which side of the ocean you live!) and played around with that information. I created a program that could provide a user with detailed information about a specific team in the league I've selected: Serie A, the top Italian soccer league.
I've been using the fantastic 'Nokogiri gem' in Ruby to scrape data from the website.

Transfermarkt is a great German website for soccer. It has a lot of data including several detailed financial values. I've used in the past to make some fun computations and analysis on European soccer.

My program shows first and foremost the current standings of the league:

Welcome to Serie A CLI
1. Juventus
2. SSC Napoli
3. Inter
4. AC Milan
5. Atalanta
6. AS Roma
7. Torino
8. Lazio
9. Sampdoria
10. Cagliari Calcio
11. Fiorentina
12. Sassuolo
13. SPAL
14. Parma
15. Genoa
16. Bologna
17. Udinese Calcio
18. FC Empoli
19. Frosinone
20. Chievo Verona

After that, it is possible to select a team based on their ranking and see information as:

(I've picked my favorite team as an example: Inter Milan)

"Inter is currently valued $635.44mn"
Total team market value in millions of $

"Inter players average age is 28,8"
The average age of the team

"They play at Stadio San Siro - Giuseppe Meazza"
This line shows the stadium where they play

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay