I am taking a bunch of pages of NCAA soccer stats and dumping them into an excel spreadsheet. However the Win/loss/tie data (WLT) spans multiple pages so I iterate through them. But the WLT only stores the last page (4 schools out of 204) of the iteration into excel. How can I get the 5 pages downloaded in the "WLT" sheet in excel? Thanks for your help....
import requests
import pandas as pd
from bs4 import BeautifulSoup
import re
import xlsxwriter
import numpy as np
import urllib.request
shutouts = "https://www.ncaa.com/stats/soccer-men/d1/current/team/31"
shutouts = pd.read_html(shutouts)[0]
SOG = 'https://www.ncaa.com/stats/soccer-men/d1/current/team/977'
SOG = pd.read_html(SOG)[0]
# players stats
shutouts_p = 'https://www.ncaa.com/stats/soccer-men/d1/current/individual/1170'
shutouts_p = pd.read_html(shutouts_p)[0]
#Win Loss Tie data
max_page_num = 6
for i in range(1,max_page_num):
print('page:', i)
page_num = str(i)
source = "https://www.ncaa.com/stats/soccer-men/d1/current/team/33/p" + page_num
WLT = pd.read_html(source)
WLT = WLT[0]
with pd.ExcelWriter('ncaastats.xlsx') as writer:
shutouts.to_excel(writer, sheet_name='shutouts')
shutouts_p.to_excel(writer, sheet_name='shutouts_p')
SOG.to_excel(writer, sheet_name='SOG')
WLT.to_excel(writer, sheet_name='WLT')