Пример #1
0
    private void LoadPlayerIntoDatabase(string playerName)
    {
        playerName = scripts.PlayerNameFirstLastFromLastFirst(playerName).ToUpper();
        //first we have to load the roster page
        var playerId = GetNHLPlayerIdFromName(playerName);
        var HTML = GetPageHTML(String.Format("http://avalanche.nhl.com/club/player.htm?id={0}", playerId));

        //since these pages are not well formatted XML, we are going to have to do this the hard way
        var position = GetHTMLInnerDiv(HTML, "plyrTmbPositionTeam\">");
        position =  position.Substring(0, position.IndexOf("-"));

        var weight = GetHTMLInnerDiv(HTML, "plyrTmbStatCaption\">Weight:</span>");
        var height = GetHTMLInnerDiv(HTML, "plyrTmbStatCaption\">Height:</span>");
        var heightInt = scripts.ConvertHeightToInches(height);
        var dob = GetHTMLInnerDiv(HTML, "plyrTmbStatCaption\">Born:</span>");
        dob = dob.Substring(0, dob.IndexOf("(Age"));

        var insertPlayerName = GetHTMLInnerDiv(HTML, "plyrTmbPlayerName\">");
        var birthplace = GetHTMLInnerDiv(HTML, "plyrTmbStatCaption\">Birthplace:</span>");
        var birthplaceArr = birthplace.Split(',');
        birthplace = birthplaceArr.Last();

        var helper = new PlayerHelper();
        helper.AddPlayerToMSSQL(insertPlayerName, position, dob, birthplace, heightInt, Convert.ToInt32(weight));
    }