Well, I wasn’t able to resolve my problem of how to get baseball standings from from MLB.com using HTTPSecureSocket since I couldn’t figure out how to obtain the full page, including data, so I didn’t really learn what I wanted to know. Instead, I obtained the standings using an API provided at: https://erikberg.com/mlb/standings.json
If you want to get the standings yourself, here is my code. The program has a button, Listbox1 to display the standings, Label1to show the date and HTTPSecureSocket1 to handle the call. Note the comment in the code which shows that there are many more variables that could be displayed.
In the button, I have:
HTTPSecureSocket1.Send("Get", "https://erikberg.com/mlb/standings.json")
In the PageReceived of HTTPSecureSocket1 I have:
[code]dim jsondata as text
jsondata = Xojo.Core.TextEncoding.UTF8.ConvertDataToText(content)
dim data as Xojo.Core.Dictionary
data = Xojo.Data.ParseJSON(jsondata)
dim date as string = data.value(“standings_date”)
date = nthfield(date, “T”, 1)
label1.text = "Date: " + date
Dim templates() As Auto = data.Value(“standing”)
listbox1.ColumnCount = 7
ListBox1.ColumnWidths = “10%, 10%, 20%, 15%, 15%, 15%, 15%”
listbox1.heading(0) = “League”
listbox1.heading(1) = “Division”
listbox1.heading(2) = “Team”
listbox1.heading(3) = “Wins”
listbox1.heading(4) = “Losses”
listbox1.heading(5) = “Pct”
listbox1.heading(6) = “GB”
for each d as Xojo.Core.Dictionary in templates
'available variables: rank, won, lost, streak, ordinal_rank, last_name, team_id,
'games_back, points_for, points_against, home_won, home_lost, away_won, away_lost,
'conference_won, conference_lost, division_won, division_lost, lastfive,
'last_ten, conference, division, points_scored_per_game, points_allowed_per_game,
'win_percentage, point_differential, point_differential_per_game, streak_type,
'streak_total, games_played
dim league as string = d.Value(“conference”)
dim division as string = d.Value(“division”)
dim team as string = d.Value(“first_name”)
dim wins as integer = d.value(“won”)
dim losses as integer = d.value(“lost”)
dim pct as string = d.value(“win_percentage”)
dim gb as double = d.value(“games_back”)
listbox1.AddRow league
ListBox1.Cell(Listbox1.LastIndex, 1) = division
ListBox1.Cell(Listbox1.LastIndex, 2) = team
ListBox1.Cell(Listbox1.LastIndex, 3) = str(wins)
ListBox1.Cell(Listbox1.LastIndex, 4) = str(losses)
ListBox1.Cell(Listbox1.LastIndex, 5) = pct
ListBox1.Cell(Listbox1.LastIndex, 6) = str(gb)
next[/code]
I suppose the could be simpler, so comments are welcome. And I really wanted to better understand HTTPSecureSockets and learn how to handle more difficult web pages because it has wider applications to me but c’est la vie.
Thanks to Tim Parnell and Ivan Tellez for your comments.