Sitemap

Warzone Package: Part 1

2 min readAug 30, 2021

--

This serves as an introduction to a series of posts analyzing performance within Call of Duty Warzone.

How to get your Warzone Match data:

First, you want to make sure you have your profile set to public. CodTracker has a nice write-up here: https://cod.tracker.gg/cold-war/articles/how-to-public-stats.

Get Peter Rigali’s stories in your inbox

Join Medium for free to get updates from this writer.

After that, you will need to access your matches from a variety of stat tracking websites, you can do this from: https://wzstats.gg/, https://www.wzranked.com/, or https://cod.tracker.gg/. While I have built scrapers for all, CodTracker has a special relationship with Activision which allows them to host all your previous games on their servers. I won't go into explicit details on how you can scrape CodTracker but a simple Selenium scraper does the trick. Once you have navigated to your matches tab

Press enter or click to view image in full size

You will be seeing a breakdown of your most recent matches. What's great about CodTracker is that at the bottom of the page you can refresh and load more matches.

Press enter or click to view image in full size

So within Selenium, you need to navigate to your page and continue to load all previous matches until you are satisfied. Then you will need to grab the links to the matches.

ml = driver.find_elements_by_xpath('//a[contains(@class,"match-row__link")]')

Next, grab the Match Ids.

lobby_links = [i.get_attribute('href') for i in ml]
lobby_ids = [i.split('/')[5].split('?')[0] for i in lobby_links]

The above step is really the only scraping that is necessary. A list of your Match Ids can be grabbed from all the above-noted websites. If this isn't the first time you are grabbing Match Ids, it will be beneficial to add a cross-check that verifies you haven't grabbed any Ids that you have already scraped. Assuming you have a saved csv with prior games that code would look like the following.

old_id_set = {str(i): True for i in set(old_df['matchID'])}

Then only select the new Match Ids:

new_id_lst = lobby_ids
lst_to_collect = [i for i in new_id_lst if i not in old_id_set]

After this, you have a list of Match Ids that you would like information on. Now you are ready to connect to the Call of Duty public API to get the match data. I have a small function for this:

The above code has two parts, the first connect_to_api grabs the match information and the second clean_api_data cleans the JSON and returns a DataFrame. You will need to concatenate all the DataFrames and then add them to your existing saved matches DataFrame.

The package can be found here: https://github.com/pjrigali/Call-Of-Duty-Warzone-Analysis

Part 2: https://medium.com/@peterjrigali/warzone-package-part-2-3ff94902f355

--

--

Peter Rigali
Peter Rigali

Written by Peter Rigali

Data Science x Call of Duty atm