collegebaseball/boydsworld_scraper.py
def _get_data(school, start, end=None, vs="all", parse_dates=True):
    """
    A helper function to send GET request to boydsworld.com and parse data
    """
    col_names = ["date", "team_1", "team_1_score", "team_2", "team_2_score", "field"]
    url = 'http://www.boydsworld.com/cgi/scores.pl'
    
    # if no end season give, obtain single-season results
    if end is None: 
        end = start
        
    try: 
        payload = {"team1":school, "firstyear":str(start), "team2":vs, \
                   "lastyear":str(end), "format":"HTML","submit":"Fetch"}

        s = requests.Session()
        r = requests.get(url, params=payload)
        response = r.text
        io = StringIO(response).read()
        dfs = pd.read_html(io=io, parse_dates=parse_dates)
        df = dfs[1].dropna(how="all", axis=1, inplace=False)
        if len(df.columns) != len(col_names):
            print("no records found")
            return pd.DataFrame()
        else: 
            df.columns = col_names
            if parse_dates:
                # make sure dates are parsed as type datetime64[ns]
                df['date'] = pd.to_datetime(df['date'], infer_datetime_format=True)
            return df
    except: 
        return pd.DataFrame()

    A helper function to send GET request to boydsworld.com and parse data
    
A helper function to send GET request to boydsworld.com and parse data
A helper function to send GET request to boydsworld . com and parse data
def _get_data(school, start, end=None, vs="all", parse_dates=True):
    col_names = ["date", "team_1", "team_1_score", "team_2", "team_2_score", "field"]
    url = 'http://www.boydsworld.com/cgi/scores.pl'
    if end is None: 
        end = start
    try: 
        payload = {"team1":school, "firstyear":str(start), "team2":vs, \
                   "lastyear":str(end), "format":"HTML","submit":"Fetch"}
        s = requests.Session()
        r = requests.get(url, params=payload)
        response = r.text
        io = StringIO(response).read()
        dfs = pd.read_html(io=io, parse_dates=parse_dates)
        df = dfs[1].dropna(how="all", axis=1, inplace=False)
        if len(df.columns) != len(col_names):
            print("no records found")
            return pd.DataFrame()
        else: 
            df.columns = col_names
            if parse_dates:
                df['date'] = pd.to_datetime(df['date'], infer_datetime_format=True)
            return df
    except: 
        return pd.DataFrame()
def _get_data ( school , start , end = None , vs = "all" , parse_dates = True ) : col_names = [ "date" , "team_1" , "team_1_score" , "team_2" , "team_2_score" , "field" ] url = 'http://www.boydsworld.com/cgi/scores.pl' if end is None : end = start try : payload = { "team1" : school , "firstyear" : str ( start ) , "team2" : vs , "lastyear" : str ( end ) , "format" : "HTML" , "submit" : "Fetch" } s = requests . Session ( ) r = requests . get ( url , params = payload ) response = r . text io = StringIO ( response ) . read ( ) dfs = pd . read_html ( io = io , parse_dates = parse_dates ) df = dfs [ 1 ] . dropna ( how = "all" , axis = 1 , inplace = False ) if len ( df . columns ) != len ( col_names ) : print ( "no records found" ) return pd . DataFrame ( ) else : df . columns = col_names if parse_dates : df [ 'date' ] = pd . to_datetime ( df [ 'date' ] , infer_datetime_format = True ) return df except : return pd . DataFrame ( )
A helper function to send GET request to boydsworld.com and parse data
A helper function to send GET request to boydsworld . com and parse data
"""
    A helper function to send GET request to boydsworld.com and parse data
    """ # if no end season give, obtain single-season results # make sure dates are parsed as type datetime64[ns]
school
start
end
vs
parse_dates