Web-scraping and Analyzing Gods Unchained Card Data
Code Walkthrough For A Data Analysis Project

This article is intended to explain the technical process of my previous post: Relative Value of Cards in Gods Unchained. There, I show results from exploratory data analysis of card data from a new blockchain based game called Gods Unchained. Below is an excerpt from my previous post that provides an overview of the game.
Gods Unchained (GU) is a digital trading card game (TCG) that runs in a downloadable app with the cards stored on the Ethereum blockchain. The game has recently gained attention when the Mythic Titan card known as Hyperion sold for 146.28 ETH, which at the time was ~$62,000! There are still two Mythic Titans hiding in the packs, however the chances to find one are one in a million chance per card reveal. The coolest thing about the game is the cards exist on the Ethereum blockchain. A major benefit of this is that the game allows the user to permanently own their digital cards, so they have the power to trade or sell their cards on sites like OpenSea. As an avid Hearthstone player who has spent lots on money on packs, I am excited for this feature. I can optimize my collection and not have to destroy my account-locked cards to obtain competitive cards like in Hearthstone.
This isn’t the only difference, the game has a Battle Royale Mode that will allow players to take copies of cards from beaten opponents and use them to survive. It’s a similar concept to survival shooter games like Fortnight or PUBG, except with cards! The Beta is expected to be released in early October ’18 and go live early January ’19. There is also a tournament happening Q1 2019 with up to a $1.6 million prize pool, depending on pack sales! The timeline for the project can be found at the bottom of the page here.
Objective
How does the Gods Unchained rarity specific pack selection system affect the value of the cards?
To gain insight on this question, I needed to get my hands on some real time card data and put it in a visual form for easy understanding. The image in Figure 1 shows the block diagram visualization of my data collection and processing pipeline. Here is a short outline of the code that you will see in this post:
- Card data gathering
- Simulation of a “perfect world” card pulling
- Processing data, storing in tables and generation of interesting plots

Let’s dive in!
Part 1a: Ad Hoc — Web Scraping
This is the painful way to get the data from data from the Gods Unchained website. They have an area on their webpage that shows all the possible cards that are available in the Genesis set, the pre-release card set. The webpage shows the card image and the amount of each card per shininess (example in Figure 1).

The cards span across 12 different pages, this can be seen on the bottom of Figure 3.

The images and information exist in the html code of webpage and we can access the data in a variety of ways. Unfortunately, we can’t simply download the page source code, because it only contains function for rendering, not the data we want. Due to this, we need to use the selenium package. Selenium allows us to download rendered html of a webpage by controlling a browser (Chrome in my case).
In our web-scraping python program, we import the following libraries:
BeautfulSoup will be used to clean up the html and pandas will hold data in a convenient structure called a dataframe. The time library is used to add delays in our code.
During the installation of these packages, I had issues with webdriver. I ended up needing to use homebrew and running the following command:
brew install webdriver Automation of the browser is a bit confusing, so here is a breakdown of the code.
Line 1: Opens an instance of Chrome
Line 3: Browser goes to the url specified in Line 2
Line 5: We add a delay because we need to manually change to 1 of the 12 pages we want data from. This is where the inefficiency on this method comes in. We need to rerun the script for each page.
Once we have the massive innerHTML data, we need to search for the data of interest. We want the card names, rarity and card count. We can use BeautifulSoup to parse the html and make it slightly easier to traverse.
We then initialize a pandas dataframe with column names and save the dataframe to a text file for the next step in the pipeline
Now we see a better way to do this.
Part 1b: Efficient Method — API
The Fuel Games team has an API (Application Program Interface) that makes it extremely easy to download any data you could want about the cards in the game. When I started this project, I was unaware of this and due to my utter excitement, used a spoon to dig a 10 foot hole (but hey it worked!).
This method uses the following libraries.
Line 1–2 & Lines 4–5: We use the request library to gain access to two different tables that contain the relevant data and store them in two separate dataframes cardDist and cardNames.
Once we have the two dataframe we do the following:
Lines 1–3: Every card has a unique id, and here we make a list of them
Lines 9–25: We use the card ids and process the tables to find the amount of cards in each
Part 2: Simulating Pack Openings
Below is the code to simulate a random selection of cards based on rarity. The rarities that were used can be found in the bottom of this GU page.
Now let’s look at the code:
Line 4: We fill a list with card rarities depending on their respective percentage.
Line 8–9: Here we (uniformly) randomly select elements of the pos list and append it to list simulated_space.
Line 19–29: All the elements are counted and placed in their four respective bins. We then add the four bins to a list and move on to add it to a bar plot.
Part 3: Performing Data Analysis
Once we have the data in a dataframe, we can process it and start the visualization.
In this code section we include matplotlib, which is an awesome package for creating plots. For this project, we only need barplots.
For the article, I only looked at rarity distribution, but I also want to see how many of each legendary and epic cards have been found. Here is the code breakdown:
Line 1: We import the text file made by the API method. If we wanted to use the webscrape method, we would have to append the files together.
Line 3–9: We initialize counts for each rarity and two dictionaries that will hold each epic/legendary card name as a key and count the total amount in existence.
Lines 11–28: We iterate through all the data and count the amount of cards in each rarity as well as store epic/legendary cards in the dictionary and count the total amount.
Finally, we take all the data and create bar plots.
Below are the resultant images (data collected on September 7th 2018 at 10:33am).



For an analysis of the data, check out my previous article: Relative Value of Cards in Gods Unchained.
Overall, this was a very fun project. If you want to download the files and run the code on your machine, checkout my GitHub. Make sure to use my referral link if you buy packs!
For any questions or comments, please drop a response below.
Notes:
Referral Link (gives me 10% of the packs you buy): https://godsunchained.com/?refcode=0x07453584C359A2b95fe115CC5eA72c56eEFE3Ee2
BTC Wallet: 3BeJmm5dVje9SmW86jg9PP1rXpddPi5vPp
ETH Wallet: 0x11D13a1c8762bdcaF05E4daC15635607C4551A33
Direct link to the GitHub files can be found here.
