Phase One Project

Stephen Sweetser
3 min readDec 14, 2020

For this project, I was going to try to find an API that I could scrape that had to do with plants or turf, since I am a turf and tree/shrub specialist by trade. However, when searching for “plants” on the API website, the only thing that came up was a Star Wars API for the first six films.

I thought, huh, I like Star Wars, let’s see what this is about.

Well, it turns out that this API had a bunch of data about the Star Wars Universe. The API looked intimidating to say the least, but I thought a challenge would be welcoming. And then, in the true spirit of 2020, a new contender (or two) entered the ring.

Right after I started the skeleton of the project (creating files, defining classes and base methods), a major snowstorm hit. During the winter I do run a plow truck, so I was forced to work for the next few days for more hours than any human should.

While I was out plowing, my roommate had returned home from a week long out of state work trip. And due to regulations, he had to be tested for COVID, which came back positive. Due to quarantine restrictions, I was not allowed to return home unless I quarantined as well, which I could not afford to do. I had to buckle down at my fiancé’s house, without my laptop, for two weeks. No laptop means no school work for two weeks. No progress on the project was made.

I was finally cleared to go back to my house and then the project began with only a few days to really crunch it out. I decided to only include the Characters, Planets, and Films in my program. I started with writing a Scraper class to scrape all the data. This was hard to really dial in because some of the values of the data being scraped was a url to another data chunk of the API. So I had to get creative.

I feel like this took away from the has-many-through relationship that we were building. Instead of an instance variable pointing to a class, it instead pointed to the url of the data for that class. So instead I built the classes by iterating over all of the Characters that were scraped, and then created a find_or_create_new method for the Planet class that scraped data for each character. Then gathered all the films the same way.

Finally it was time to work on my CLI. The most challenging part was paginating my data so that the user did not need to scroll. After some trial and error, and a generous use of pry, I was able to make menus a little more user friendly.

The loading times were killing me as it was taking a long time to scrape (there are a total of 82 characters, and they were being iterated through twice and scraping data each time) and having to test out features was hard with having to wait over 2 minutes every time I ran the program. So I decided to create all the classes by scraping the data from the website for each. Now the load time is barely noticeable. All that is left is to make the CLI a little more beautiful before my review.

--

--