import requests
from bs4 import BeautifulSoup


def getBoxscoreURLsFromPlayer(playerId):
    """
    Put in a player id and get all boxscores for that player.
        - can be updated to specify after which date. 
    """
    
    r = requests.get('https://www.pro-football-reference.com/players/'+ playerId[0] + '/' + playerId + '/gamelog/')
    text = r.text.replace('<!--', '').replace('-->', '')
    soup = BeautifulSoup(text, 'lxml')
    
    boxscores = []
    for url in soup.findAll(class_='overthrow table_container')[0].findAll('a'):
        if '/boxscores/' in str(url):
            boxscores.append('https://www.pro-football-reference.com' + str(url)[9:36])
    for url in soup.findAll(class_='overthrow table_container')[1].findAll('a'):
        if '/boxscores/' in str(url):
            boxscores.append('https://www.pro-football-reference.com' + str(url)[9:36])
            
    return boxscores