Project Overview

This focus of this report is the analysis of a sample of user reviews submitted for Overwatch, which were scraped from the metacritic website (https://www.metacritic.com/game/pc/overwatch/user-reviews). In addition to identifying patterns in these reviews, a sample of reviews for Call of Duty: Warzone is also scraped and analyzed for comparative purposes.

Two primary types of analyses were performed.

  1. Analysis of trends in review scores over time.
  2. An application of text analytics to determine which aspects of the game are receiving positive or negative feedback.

Analysis of the review scores over time finds that video games appear to receive there highest ratings in the first month following their initial release, after which there is a step drop off, followed by a gradual decline. The decrease in review score between the first and second months is especially pronounced for Overwatch, although this game initially received many more highly positive reviews. The text analysis identifies specific aspects of each game that are associated with positive and negative reviews, negative reviews seem better suited to this purpose as the language in positive reviews tends to be more general.

By performing these analyses, this report provides evidence of trends found in video reviews and identifies atypical patterns which may need further investigation. Additionally, the analysis in this report serves as an example of how text analysis can be used to generate insights from unstructured data. Throughout this document summary charts and tables will be provided as well as examples of the R code used for data processing and analysis. Although the focus of this project is the analysis of the text and scores contained in user reviews, an example of the Python code used to acquire this data is included in the appendix.

Data Analyzed

The raw data for Overwatch contains 1,371 reviews, each of which consists of a review date, review score, and review text. A sample of the raw data is shown below.

Data Preview of User Reviews Submitted for Overwatch
date score text
Jan 9, 2018 5 It would be a solid game. But you should expect a less buggy game and especially a server with less random disconnects. The character are rather balanced and the events are entertaining. Still the other flaws just pull it down. Don’t get me started on the ranking system and the matchmaking.
Sep 14, 2017 7 Now that the hype has settled I think I should give a fair analysis on this game and whether or not it’s worth the $40-$60 you will spend. One thing that I LOVE about this game is how easy it is to play. No confusing menus or other crap I don’t care, just simple click what you want which is vital in an action packed game like this. The characters REALLY stand out. I love all of them! (except MEI I HATE HER) All of them have there own charm and make the game even more fun. The art style is also nice but pretty basic. And the maps are seriously the best maps for a multiplayer shooter like Overwatch. But a big problem I have with the game is how lacking in content it really is. Especially for a $40-$60 game. PLEASE BLIZZARD, ADD IN A STORY MODE! Also I think this game really didn’t diverse GOTY in 2016. And just for the fact it got THAT award makes this game feel a little OVERRATED. Sorry ¯(ツ)/¯. Overall I would recommend. PS, this game runs SUPER well on most computers that are pretty good in terms of graphical power.
Jun 3, 2020 9 The game is fun and a lot of effort has been put into it, the main problem is the balance changes. You had the double shield in the meta for ages, you got brig who is so broken I have seen people one-trick her to gm with a 93 winrate. Gold players were able to make it to gm on her. Lots of things have been fixed, but the dev team really cares about the causal players, not the competitive ones.
Apr 23, 2017 9 This game is extremely enjoyable, with a fun multiplayer. It will keep you entertained for hours upon hours with just how unique it is. However, lack of a campaign keeps this from the perfect 10/10 it well and truly deserves.
Apr 15, 2020 1 This review contains spoilers. After they nerfed Widowmakers ass it has been harder to find my purpose in this online life i give it 420/69 lmao

Before analysis, several issues in the raw data need to be addressed, the following data processing steps are performed

  1. Validation and correction of dates
  2. Validation and correction scores
  3. Removal of non-ascii & non-standard characters (such as in the second record in the preview above)
  4. Identification and removal reviews submitted in languages other than English.

Validating and Correcting Dates

  d1$date2=gsub("[[:punct:]]","",d1$date)
  d1$date2=gsub(" ","",d1$date2) %>% tolower()
  d1$date3<-as.Date(d1$date2,"%b%d%Y")
  pander(summary(d1$date3))
Min. 1st Qu. Median Mean 3rd Qu. Max. NAs
0016-06-12 2016-05-25 2016-06-16 1828-02-06 2018-01-17 2022-03-28 284

The code above converts the date column from a “character” format to a “date” format, summary stats are then calculated to identify any problems with date conversion. Clearly there are some issues which need to be addressed as we can see 284 missing values and a minimum year equal to “0016.” These issues are corrected in the code below.

########################
# Formatting Dates     #
########################

  # Adjust NA Dates
  no_date=d1[which(is.na(d1$date3)),]
  no_date$sp1<-sapply(strsplit(no_date$date,",",fixed=T),"[",1)
  no_date$sp2<-sapply(strsplit(no_date$date,",",fixed=T),"[",2) %>% trimws()
  no_date$sp1a<-sapply(strsplit(no_date$sp1," ",fixed=T),"[",1)
  no_date$sp1b<-sapply(strsplit(no_date$sp1," ",fixed=T),"[",2)
  no_date$spnew<-paste(no_date$sp1a,no_date$sp1b,sep="0")
  no_date$new_date<-paste(no_date$spnew,no_date$sp2,sep="") %>% tolower()
  no_date$date3<-as.Date(no_date$new_date,"%b%d%Y")
  no_date2<-no_date %>% dplyr::select(-sp1,-sp2,-sp1a,-sp1b,-spnew,-new_date,-date2,-date)
  
# Restack
  d1a<-d1[is.na(d1$date3)==F,]
  d1b<-d1a %>% dplyr::select(-date,-date2)
  d2<-dplyr::bind_rows(d1b,no_date2)
  
# adjust years missing "20"
  d2$year=year(d2$date3)
  year1<-d2$year
  new_year<-c()
  for (i in 1:length(year1)){
    if(year1[i]<2000 & is.na(year1[i])==F){
      new_year[i]<-as.numeric(paste("20",year1[i],sep=""))
    }else{
      new_year[i]=year1[i]
    }
  }
  
  # create days,months and quarters after release variables
  d2$year<-new_year
  d2$temp<-paste(month(d2$date3),day(d2$date3),d2$year,sep="/")
  d2$new_date<-mdy(d2$temp)
  d2$days_after_realse<-d2$new_date-as.Date("2016-05-24")
  d2$months_after_realse<-round(d2$days_after_realse/30.44)
  d2$quarters_after<-ceiling(d2$months_after_realse/3)
  d2$quarter<-min(d2$new_date)+(d2$quarters_after*3*30.44)

After executing the code above summary statistics are recalculated for review date producing the following results which indicate that the issues initially identified have been corrected.

Min. 1st Qu. Median Mean 3rd Qu. Max.
2016-05-24 2016-05-28 2016-08-13 2017-09-10 2018-09-29 2022-03-28

The earliest user review in this sample comes from May 24th 2016, the same date as the games release, the last is on March 23rd 2022. The median date is equal to August 13th 2016 which indicates the reviews in this sample tend to come from earlier time periods. This is makes sense as we would expect more reviews to be submitted shortly after release. For a more complete picture of the dates associated with this sample of user reviews, reviews are aggregated to three month periods (quarters), where the first “quarter” includes all reviews submitted in the 3-month period following release. A chart which depicts the frequency of reviews by quarter is shown below.

The results in this chart again fall in line with expectations as we can see that the majority of the reviews were submitted in the first two quarters. After this point there is a steep decline and general plateau of review frequency. A slight increase in review frequency can be seen at the beginning of 2020, this could have been a result of the Covid lockdown, which may have led more people to focus on stay-at-home activities such as video games, however the increase appears fairly small and the variation in review frequency makes it difficult to draw any definitive conclusions.

Validating and Correcting Review Scores

  score_ft1<-with(d2,table(score)) %>% as.data.frame()
  score_ft1$Percent<-score_ft1$Freq/sum(score_ft1$Freq)
  score_ft1$Percent<-scales::percent(  score_ft1$Percent)
  
  kbl(score_ft1) %>%
    kable_styling(bootstrap_options = c("striped", "hover", "condensed"),full_width = F)
score Freq Percent
0 312 22.757%
1 72 5.252%
2 51 3.720%
3 52 3.793%
4 67 4.887%
5 88 6.419%
6 88 6.419%
7 79 5.762%
8 103 7.513%
9 160 11.670%
10 296 21.590%
90 1 0.073%
95 2 0.146%
# Adjust scores submitted on a scale of 0-100
  d2$score<-ifelse(d2$score>10,d2$score/10,d2$score)

After adjusting the three scores which appear to have been reported out of 100 (the scores of 90 and 95 in the table above), we can see the corrected overall distribution of scores.

As one might expect the review scores for Overwatch tend towards the “extreme” values, this likely results from a tendency of players to only submit reviews when they feel strongly about the game. The review score of 0 is the most frequent and accounts for 22.8% of reviews analyzed, this is followed by 10 and then 9 which account for 21.6% and 11.7% of the reviews analyzed.

Average Review Score By Quarter

Next trends in review scores over time will be investigated. In the chart below the average review score by quarter is shown, where the size of each point corresponds to the number of review scores included in the average. Additionally, a simple line of best fit has been added to this chart to show the general trend in average review score.

Although sporadic, there is a general negative trend in average review score. After the first quarter, with an average score of 7.52 and 472 reviews, the average review score never exceeds 5.5. This general negative trend may not be surprising for a game such as Overwatch which is entirely focused on online multi-player game play. As games get older the online community may shrink or become less friendly towards newcomers as the skill gap widens. This is less true for single player games where a player’s experience is likely to be very similar regardless of whether they bought the game immediately after release or years later. The last observation in the chart is a very low outlier but this results from the fact that only four reviews could be found for this time period.

The most concerning observation in this chart is the large initial decrease in average review score between the first and second quarter where the score drops from 7.52 to 4.94. This may be a pattern which is commonly observed in user reviews, where upon the games initial release fans who were already excited about the game submit glowing reviews, and in later periods, reviews may tend to be submitted by more casual players. To test these theories reviews for a comparable game were gathered and analyzed using the same methods.

Comparative Analysis: Data for an Approriate Comparator

As a first step in determining how atypical the observed negative trend and large initial decrease in average review scores for Overwatch are, a sample of user reviews for another game was scraped from the metacritic website. The game chosen for comparison was Call of Duty: Warzone.

Although their many differences between Overwatch and Call of Duty: Warzone, Warzone came out much more recently and is strictly a “Battle Royale” type of game, there are several similarities which make it an appropriate for this type of comparative study. First, the game has been popular, although the time period over which we can analyze reviews will be shorter, a popular game with a substantial amount of user reviews submitted needs to be chosen if a comparison to the decrease observed in the review scores for Overwatch is to be made.

Second, the game play for Call of Duty: Warzone is strictly competitive, online, and multi-player/team oriented. This means that the reviews for Warzone should, in theory, focus on similar topics such as matchmaking, online game performance, and interaction with other players. If a game which included a “Story Mode” or single player campaign was chosen, the reviews analyzed could be concerned with very different criteria such as enemy design/A.I. and the quality of the overall story being told.

A data set of 697 user reviews for Call of Duty: Warzone covering the time period of March 10th, 2020 to March 22nd 2022 was scraped from the metacritic web site. After applying the same data processing techniques used for the Overwatch reviews, distributions of the review frequency and reviews scores were calculated. Summary statistics for the date range analyzed and the distribution of review frequency by quarter start date are provided below.

Min. 1st Qu. Median Mean 3rd Qu. Max.
2020-03-10 2020-04-09 2020-08-09 2020-10-31 2021-04-24 2022-03-22

The first review for Call of Duty: Warzone. was submitted on March 10th, 2020 the same day as the games initial release. Although the reviews for Call of Duty: Warzone. cover a shorter time period we see similar trends to the reviews gathered for Overwatch. Reviews are frequently submitted shortly after the initial release then tend to tail off after roughly 6 months.

Next we turn to examining the distribution of user review scores for Call of Duty: Warzone.

  #Warzone score distribution
  wz_score_ft<-with(wz3,table(score)) %>% as.data.frame()
  wz_score_ft$Percent<-wz_score_ft$Freq/sum(wz_score_ft$Freq)
  wz_score_ft$Percent<-scales::percent(wz_score_ft$Percent,accuracy = 0.01)
  wz_dist_plot<-ggplot(wz_score_ft)+geom_col(aes(x=score,y=Freq))+
    geom_text(size=3,aes(x=score,y=Freq,label = Percent), vjust = -0.5)+
    xlab("Review Score")+ylab("Frequency")+
    ggtitle("Distribution of Review Scores\nfor Call of Duty: Warzone")
  
  wz_dist_plot

Similarly to Overwatch the distribution of scores for Call of Duty: Warzone. exhibit a tendency towards extreme values, however for this game, highly negative reviews are much more common. Zero is the most frequently assigned score and while this was also true for Overwatch, scores of 0 account for 47.3% of the reviews submitted for Call of Duty: Warzone whereas for Overwatch they were only 22.8%.

In addition to fewer highly negative reviews, Overwatch also received more highly positive reviews, a score of 10 was the second most frequently assigned score and scores of 9 or higher account for 33.5% of reviews. For Call of Duty: Warzone a score of 1 was the second most commonly assigned score and scores of 9 or higher account for only 9.7% of the reviews analyzed.

Comparative Analysis of Review Scores Overtime

For a comparative analysis of review scores over time, both data sets are restricted to only include reviews which where submitted within the first year of the games initial release. The average review score is then aggregated at the monthly level. Just as in the chart showing the average review score by quarter, the size of each point in these charts correspond to the number of reviews submitted in this time period and a simple line of best fit has calculated for this data.

Negative trends are observed in the average scores for both Overwatch and Call of Duty: Warzone, this aligns with the theory that after initial release, there will be a tendency for players to submit more positive reviews. This tendency could result from the fact that these players were already excited about the game and more likely to enjoy it, or simply a tendency for the “buzz” around a new video game to inflate reviews. Although no formal analysis of movie reviews is conducted here, movies tend receive their highest IMDB rating shortly after release and after a few weeks the rating usually falls, a similar mechanic could be in play here.

The charts above only partially confirm the theory that the initial sharp decrease in user reviews observed for Overwatch is typical for this type of video game. In the first two months after release the average score for Overwatch decreases from 7.52 to 5.09 (decerase of 32.3%). For Call of Duty: Warzone. the average review score drops from 3.48 to 2.7 (decrease of 22.4%). While a similar pattern is observed for Call of Duty: Warzone the decrease is considerably larger for Overwatch. Additionally, the reviews for Call of Duty: Warzone “bounce back,” in the following months average review scores close to the initial value of 3.48 are achieved multiple times, this is not the case for Overwatch.

Some of these differences could be due to the fact that Overwatch simply had farther to fall. The average scores for Call of Duty: Warzone tend to fall between 0 and 4 and there is only some much variation that can occur in this narrow range, whereas the typical range of average scores for Overwatch is around twice that size.

Overall this analysis finds that an initial decrease is not unusual, but the sheer size of this decrease and the fact that review scores for Overwatch never recover to their initial level may indicate that additional factors are involved.

Text Analysis

In order to determine what aspects of the game are driving users’ reviews, a text analysis of the reviews is conducted. To start, reviews written in non-english languages are removed, then the data is subset to only reviews which have a review score less than 3 or greater than 7, this in effect should identity “highly negative” and “highly positive” reviews. The resulting data set includes a total of 967 reviews for Overwatch, where 547 have a review score of 8 or higher and 420 have a review score of 2 or lower. For Call of Duty: Warzone the resulting data set contains 362 highly negative and 87 highly positive reviews. In the code below document-term matrices are created for the reviews associated with each game, and additional text cleaning is applied, such as the removal of punctuation and “stopwords” from the data.

# Function for building Word clouds according to binary category (positive vs. negative review)

  build_word_comp<-function(dtm,flag_vec){
    p_words <- colSums(dtm) / sum(dtm)
    
    pcomp_words <- lapply(unique(flag_vec), function(x){
      rows <- dtm[ flag_vec == x , ]
      rows <- rows[ , colSums(rows) > 0 ]
      colSums(rows) / sum(rows) - p_words[ colnames(rows) ]
    })
    pcomp_words2<-pcomp_words[which(unique(flag_vec))]
    return(pcomp_words2)
  }
  
  # creating document term matrix for overwatch
  dtm1 <- CreateDtm(doc_vec =d5$text2, 
                    doc_names = d5$id, 
                    ngram_window = c(1,2),
                    stopword_vec = c(stopwords::stopwords("en"), 
                                     stopwords::stopwords(source = "smart")), 
                    lower = TRUE, 
                    remove_punctuation = TRUE, 
                    verbose = F)
  
  
  tf_mat <- TermDocFreq(dtm1)
  tfidf0 <- t(dtm1[ , tf_mat$term ]) * tf_mat$idf
  tfidf <- t(tfidf0)
  
  wc1<-build_word_comp(dtm1,d5$good_flag)
  wc2<-build_word_comp(dtm1,d5$bad_flag)
  
  # creating document term matrix for warzone
  wzdtm1 <- CreateDtm(doc_vec =wz6$text2, 
                    doc_names = wz6$id, 
                    ngram_window = c(1,2),
                    stopword_vec = c(stopwords::stopwords("en"), 
                                     stopwords::stopwords(source = "smart")), 
                    lower = TRUE, 
                    remove_punctuation = TRUE, 
                    verbose = F)
    
    
  wztf_mat <- TermDocFreq(wzdtm1)
  wztfidf0 <- t(wzdtm1[ , wztf_mat$term ]) * wztf_mat$idf
  wztfidf <- t(wztfidf0)
  
  wzwc1<-build_word_comp(wzdtm1,wz6$good_flag)
  wzwc2<-build_word_comp(wzdtm1,wz6$bad_flag)

Word clouds are created for the words which distinguish good vs. bad reviews. Word clouds can be created using many different metrics, but generally are designed to identify words which distinguish different groups of documents. The size of the word in the word cloud corresponds to the chosen metric. In this example the the metric used is the increase in relative frequency of a term, when we compare the term’s relative frequency across all reviews to the term’s relative frequency across only good or bad reviews. The “top” 25 terms for good and bad reviews of Overwatch are depicted in the word clouds below.

It is unsurprising to see that many of the words in the word clouds above have strong positive or negative connotations. Words such as “fun” and “great” can be found in the good review word cloud whereas the bad review word cloud includes “trash,” “worst” and “bad.” Perhaps more interesting are the words which do not have a strong positive or negative connotation as these tell us what the users find “fun” or consider to be “trash.”

For example both the terms “characters” and “heros” appear in the positive review word cloud, which likely indicates that the players writing these reviews generally enjoy the variety and design of characters. Similarly the words “community,” “matchmaking” and “matchmaking_system” all appear in the negative review word cloud indicating that these reviews generally have problems with the online community and matchmaking system.

The same analysis is now performed for the good and bad reviews of Call of Duty: Warzone, the resulting word clouds are shown below.

wordcloud::wordcloud(words =names(unlist(wzwc1[[1]])), 
                           freq = unlist(wzwc1[[1]]), 
                           max.words = 25, 
                           random.order = FALSE, 
                           colors=my_blues)

 text(x=0.5, y=0.99, "Word Cloud for Good Reviews of Call of Duty: Warzone")

my_blues=c("#9ecae1","#6baed6","#4292c6","#2171b5","#08306b")

wordcloud::wordcloud(words =names(unlist(wzwc2[[1]])), 
                           freq = unlist(wzwc2[[1]]), 
                           max.words = 25, 
                           random.order = FALSE, 
                           colors=my_blues)

text(x=0.5, y=0.99, "Word Cloud for Bad Reviews of Call of Duty: Warzone")

In the word clouds for Call of Duty:Warzone we can see that good reviews tend to mention the battle royale aspect of the game as well as mention playing with friends. This word cloud seems to indicate that players writing positive reviews are already fans of Call of Duty and excited to have a battle royale game mode to play with friends.

In the negative review word cloud we see two main themes in the words depicted. First, the most frequent problem the players submitting these reviews seem to encounter is enemy players cheating, as “cheaters” is one of the most prominent words in this image, additionally the term “hackers” can be seen near the bottom of the word cloud. The reviews leaving negative reviews also seem to have issues with the games performance online, as we can see the terms “crashes,” “bugs,” “error,” and “servers” in this word cloud.

Conculsions

In this report, user reviews for Overwatch were scraped from the metacritic website (https://www.metacritic.com/game/pc/overwatch/) and then analyzed to determine trends in user reviews over time. User reviews from the same website for Call of Duty:Warzone were also scraped and analyzed for comparative purposes. Additionally, a text analysis of the words associated with highly positive or highly negative reviews is performed to determine which features of these games may be driving positive vs. negative reviews.

Analysis of the review scores overtime indicate that Overwatch tends to receive much more favorably reviews then Call of Duty:Warzone. This analysis also finds that positive reviews are much more common in the first month after a game’s initial release. The average scores for both video games decrease by over 20% in the second month after release and tend to continue this downward trend, but at a slower pace.

Although this decrease was observed for both games, it was substantially larger for Overwatch, and unlike Call of Duty:Warzone, the average review score for Overwatch never again reached a level close to the score it received in the first month after release. Further analysis would need to be conducted to establish how atypical this pattern is and identify potential causes.

The text analysis of these reviews, in combination with a web scraping program, serve as an example of how these techniques can be applied to publicly available data and create insights into consumer sentiment. For the reviews analyzed in this report, the highly positive reviews tended to be less informative than the highly negative. Highly positive reviews appear to be less likely to mention specific aspects of the game, and instead explain in general terms how “fun” and “great” the game is. Additional text processing or alternative methods of analysis may be needed for this data, however some general observations can still be made concerning the positive reviews.

For Overwatch, positives reviews appear to focus on the unique gameplay, characters, and maps. For Call of Duty:Warzone, positive review seem to focus on the “battle royale” style of gameplay and often mention the “Call of Duty” franchise in general terms. This may indicate that the positive reviews for Warzone are predominantly submitted by players who are already playing “Call of Duty” games and are excited to have a battle royale game at their disposal.

For both games, analysis of the negative reviews was able to identify specific aspects which may be driving player’s negative opinions. For Overwatch, the aspects of the game which were most frequently mentioned in these negative reviews were the matchmaking system and a “toxic” community. In addition to the terms “matchmaking” and “matchmaking system” appearing in the negative review word cloud, we also see the terms “balance/unbalanced” reinforcing the idea that players are frustrated with the current system. The negative reviews for Call of Duty:Warzone primarily focus on the game’s online performance, as they commonly refer to “bugs” and “server crashes,” and problems with other players “cheating” or “hacking”.

Limitations and Potential for Further Analysis

This report ends with a discussion of the limitations of the analyses performed and potential ways to overcome these limitations or expand upon analysis.

The primary limitation of this analysis concerns the quantity and quality of the data analyzed. Although over 1,300 reviews for Overwatch were initially scraped, after cleaning and processing, this number was reduced 967. The samples become even smaller when aggregating reviews at the monthly level. Comparing tends overtime becomes difficult when, with the exception of the first month after release, the months analyzed contain relatively few reviews. Furthermore, the high variability in review scores makes in all the more important for a large sample to be gathered. Although no statistical test are performed in this report, the high variability would make establishing statistical significance difficult without a larger sample.

The scope of this report only includes two games, as previously mentioned, analysis of review scores for a larger selection of games would be helpful in determining how atypical certain trends reviews over time are for specific games.

Although analysis of the text in negative reviews was relatively successful at identifying specific aspects of each game, this was less true for the text in positive reviews. One potential way to overcome this issues would apply more rigorous text processing to the reviews. If we are not concerned with words which describe the players sentiment (such as “good,” “bad,” “worst” etc.) these could be removed prior to analysis. Additionally, targeted analysis of specific aspects of the game could be conducted. This report analyzes positive and negative reviews in an attempt to identify specific aspects of the each game, but instead a specific aspect of the games could be chosen prior to analysis and then players’ opinion of this aspect could be tracked overtime. For example the frequency of the word “matchmaking” (and whether is is mentioned in a positive or negative review) could be tracked in an effort to identify specific points in time when players develop a more negative outlook of the matchmaking system.

Finally, the last avenue of additional analysis which will be discussed is the use of a sentiment library or sentiment model which could be applied to review text. Using a sentiment library (lexicon) or model would have several advantages over reliance on the review scores assigned. First, it would allow sentiment to be calculated for each sentence in a review, which would greatly increase the sample size. This would also allow for the identification of good aspects of a game in a bad review or bad aspects of a game in a good review. For example a positive review may state something along the lines of “problems with the matchmaking system keep me from giving it a 10/10” where even though the overall review views the game favorably, the matchmaking system is not. However, using a sentiment library or model would come with its own hurdles. It is likely a new model would need to be specially trained for analysis of video game reviews due to the unique language and jargon this text contains. Generic pre-existing sentiment models would be unlikely to account for the context of words such as “nerf,” “broken,” or “smurf,” as they have specific meanings in the video game community separate from their traditional use.

Python Webscraping Appendix

#Python Set Up
from selenium import webdriver
import pandas as pd
import time

# Path to web driver
driver = webdriver.Chrome(executable_path="C:/Users/MBergenholtz/Desktop/Coursera/Work Products/chromedriver_win32 (1)/chromedriver.exe")

#Load list of urls to scrape
url_list=pd.read_csv("C:/Users/MBergenholtz/Desktop/Coursera/Work Products/metacritic overwatch urls.csv")
url=url_list["urls"].copy()

#Launch Web driver & go to first url in list 
driver.get(str(url[0]))
            
# Loop containers 
rev_text=[]
rev_date=[]
rev_score=[]

# Define loop index

url_index=list(range(0,len(url)))

# Begin web scraping loop 

for i in url_index:
  
    # Load web page
    driver.get(str(url[i]))
    time.sleep(4)
    
    # Identify all reviews on webpage 
    lis=driver.find_elements_by_class_name("review_content")
    rev_range=range(0,len(lis))
    
    # Open Review Loop 
    for review in rev_range:
        rev=lis[review]
        
        # Check if review text need expanding
        check_spans = rev.find_elements_by_tag_name("span")

        for span in check_spans:
            if span.text=="Expand":
                expand=span
                expand.click()
                break
            
        # Get Review content: Date, Score and Text
        rev=lis[review]
        rev_body=rev.find_element_by_class_name("review_body")
        rev_grade=rev.find_element_by_class_name("review_grade")
        date=rev.find_element_by_class_name("date")
        rev_text.append(rev_body.text)
        rev_score.append(rev_grade.text)
        rev_date.append(date.text)
        print("Page "+str(i)+" Review "+str(review)+" Complete")
    
    
# Format data.frame of results & save to csv
df=pd.DataFrame()
df["date"]=rev_date
df["score"]=rev_score
df["text"]=rev_text
df.to_csv("C:/Users/MBergenholtz/Desktop/Coursera/Work Products/Warzone reviews.csv")