I'm trying to extract the Teams playing each day and the Active & Inactive players in each team's lineup. The URL for the page I'm trying to scrape is: https://stats.nba.com/lineups/. I've been using BeautifulSoup to try to get this data, and have tried a few methods to get to it, but I can't seem to extract anything within the
<div class="landing__flex-col lineups-game" data-game-state="3" nba-data-game="game" nba-with ng-include ng-repeat="game in games" src="'/lineups-template.html'">.
I want to get the teams in each matchup within each
<div class="landing__flex-col lineups-game" data-game-state="3" nba-data-game="game" nba-with ng-include ng-repeat="game in games" src="'/lineups-template.html'">,
and each player within the
<div class="columns small-6 lineups-game__team lineups-game__team--htm" nba-with nba-with-data-team="game.h" ng-include src="'/lineups-team-template.html'">.
So within the sample of html code below, I want to get the text for MEM, CHA, J. Valanciunas, and J. Crowder, and eventually do this for each player for each team.
<div class="landing__flex-row lineups-games" ng-show="isLoaded && hasData" aria-hidden="false">
<!----><!----><div class="landing__flex-col lineups-game" ng-repeat="game in games" nba-with="" nba-data-game="game" data-game-state="3" ng-include="" src="'/lineups-template.html'">
<div class="lineups-game__inner row">
<div class="columns small-12 lineups-game__title">
<a href="/game/0021900154/">
<span class="lineups-game__team-name">MEM</span>
<span class="lineups-game__vs">vs</span>
<span class="lineups-game__team-name">CHA</span>
<span class="lineups-game__status hide-for-live-game">Final</span>
<span class="lineups-game__status hide-for-pre-game hide-for-post-game">Live</span>
</a>
</div>
<!----><div class="columns small-6 lineups-game__team lineups-game__team--vtm" nba-with="" nba-with-data-team="game.v" ng-include="" src="'/lineups-team-template.html'">
<!----><!----><div ng-if="team.hasBench" nba-with="" nba-with-data-team="team" ng-include="" src="'/lineups-confirmed-roster-template.html'">
<div class="lineups-game__header">
<img team-logo="" class="lineups-game__team-logo team-img" abbr="MEM" type="image/svg+xml" src="/media/img/teams/logos/MEM_logo.svg" alt="Memphis Grizzlies logo" title="Memphis Grizzlies logo">
<span class="lineups-game__team-name">MEM</span>
</div>
<div class="lineups-game__roster-type lineups-game__roster-type--confirmed">Active List</div>
<ul class="lineups-game__roster lineups-game__roster--official">
<!----><li class="lineups-game__player lineups-game__player--starter" ng-repeat="pl in team.starters">
<a href="/player/202685/">
<span class="lineups-game__pos">C</span>
<span class="lineups-game__name">J. Valanciunas</span>
</a>
</li><!----><li class="lineups-game__player lineups-game__player--starter" ng-repeat="pl in team.starters">
<a href="/player/203109/">
<span class="lineups-game__pos">SF</span>
<span class="lineups-game__name">J. Crowder</span>
</a>
I tried by doing the following, among other methods, to no avail:
gamesSource = urllib.request.urlopen('https://stats.nba.com/lineups/').read()
gamesSoup = bs.BeautifulSoup(gamesSource,'html.parser')
teams = gamesSoup.find_all("span",{"class":"lineups-game__teams-name"})
All that ever gets returned is an empty list, and when I try to get a specific 'span' line, all that gets returned is 'None'.
Let me know what's going wrong, and what I can do to access the information I'm trying to get.
Thanks.