次のhtml形式の統計情報の抽出をプログラムしようとしています... awayPlayers = [['Carmelo Anthony'、 '30'、 '19'、 '5'、 '3' ]、['Kristaps Porzingis' ....]]をクリックして、自分のフォーマットで簡単に表示し、データを扱うことができます。Beautiful Soup Parsing Stats
私はBeautifulSoupの基本を持っていますが、このプロジェクトが進行する限りは、私が望む統計はすべて単純にtdタグで囲まれています。ちょっとした助けが大いにあります!!!
<div class="standings">
<h3 class="standings-title">NYK</h3>
<div class="awayTeam-boxscore">
<table>
<tbody>
<tr class="table-header">
<td>Name</td>
<td>MIN</td>
<td>PTS</td>
<td>REB</td>
<td>AST</td>
</tr>
<tr>
<td><a href="/feature/player/carmelo_anthony/index.html?locale=en_US">C.Anthony</a></td>
<td>30</td>
<td>19</td>
<td>5</td>
<td>3</td>
</tr>
<tr>
<td><a href="/feature/player/kristaps_porzingis/index.html?locale=en_US">K.Porzingis</a></td>
<td>33</td>
<td>16</td>
<td>7</td>
<td>0</td>
</tr>
<tr>
<td><a href="/feature/player/joakim_noah/index.html?locale=en_US">J.Noah</a></td>
<td>20</td>
<td>0</td>
<td>6</td>
<td>3</td>
</tr>
<tr>
<td><a href="/feature/player/courtney_lee/index.html?locale=en_US">C.Lee</a></td>
<td>20</td>
<td>0</td>
<td>3</td>
<td>0</td>
</tr>
<tr>
<td><a href="/feature/player/derrick_rose/index.html?locale=en_US">D.Rose</a></td>
<td>30</td>
<td>17</td>
<td>3</td>
<td>1</td>
</tr>
<tr>
<td><a href="/feature/player/brandon_jennings/index.html?locale=en_US">B.Jennings</a></td>
<td>21</td>
<td>7</td>
<td>3</td>
<td>5</td>
</tr>
<tr>
<td><a href="/feature/player/kyle_oquinn/index.html?locale=en_US">K.O'Quinn</a></td>
<td>15</td>
<td>2</td>
<td>5</td>
<td>1</td>
</tr>
<tr>
<td><a href="/feature/player/lance_thomas/index.html?locale=en_US">L.Thomas</a></td>
<td>17</td>
<td>2</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td><a href="/feature/player/justin_holiday/index.html?locale=en_US">J.Holiday</a></td>
<td>26</td>
<td>8</td>
<td>6</td>
<td>2</td>
</tr>
<tr>
<td><a href="/feature/player/willy_hernangomez/index.html?locale=en_US">W.Hernangomez</a></td>
<td>9</td>
<td>4</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td><a href="/feature/player/sasha_vujacic/index.html?locale=en_US">S.Vujacic</a></td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td><a href="/feature/player/mindaugas_kuzminskas/index.html?locale=en_US">M.Kuzminskas</a></td>
<td>9</td>
<td>7</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td><a href="/feature/player/ron_baker/index.html?locale=en_US">R.Baker</a></td>
<td>7</td>
<td>5</td>
<td>1</td>
<td>0</td>
</tr>
</tbody>
</table>
</div>
<h3 class="standings-title">CLE</h3>
<div class="homeTeam-boxscore">
<table>
<tbody>
<tr class="table-header">
<td>Name</td>
<td>MIN</td>
<td>PTS</td>
<td>REB</td>
<td>AST</td>
</tr>
<tr>
<td><a href="/feature/player/lebron_james/index.html?locale=en_US">L.James</a></td>
<td>32</td>
<td>19</td>
<td>11</td>
<td>14</td>
</tr>
<tr>
<td><a href="/feature/player/kevin_love/index.html?locale=en_US">K.Love</a></td>
<td>25</td>
<td>23</td>
<td>12</td>
<td>2</td>
</tr>
<tr>
<td><a href="/feature/player/tristan_t_thompson/index.html?locale=en_US">T.Thompson</a></td>
<td>22</td>
<td>0</td>
<td>6</td>
<td>0</td>
</tr>
<tr>
<td><a href="/feature/player/jr_smith/index.html?locale=en_US">J.Smith</a></td>
<td>25</td>
<td>8</td>
<td>3</td>
<td>2</td>
</tr>
<tr>
<td><a href="/feature/player/kyrie_irving/index.html?locale=en_US">K.Irving</a></td>
<td>30</td>
<td>29</td>
<td>2</td>
<td>4</td>
</tr>
<tr>
<td><a href="/feature/player/richard_jefferson/index.html?locale=en_US">R.Jefferson</a></td>
<td>26</td>
<td>13</td>
<td>4</td>
<td>1</td>
</tr>
<tr>
<td><a href="/feature/player/iman_shumpert/index.html?locale=en_US">I.Shumpert</a></td>
<td>14</td>
<td>2</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td><a href="/feature/player/mike_dunleavy/index.html?locale=en_US">M.Dunleavy</a></td>
<td>23</td>
<td>4</td>
<td>4</td>
<td>2</td>
</tr>
<tr>
<td><a href="/feature/player/channing_frye/index.html?locale=en_US">C.Frye</a></td>
<td>14</td>
<td>6</td>
<td>4</td>
<td>0</td>
</tr>
<tr>
<td><a href="/feature/player/jordan_mcrae/index.html?locale=en_US">J.McRae</a></td>
<td>6</td>
<td>2</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td><a href="/feature/player/deandre_liggins/index.html?locale=en_US">D.Liggins</a></td>
<td>12</td>
<td>4</td>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td><a href="/feature/player/chris_andersen/index.html?locale=en_US">C.Andersen</a></td>
<td>6</td>
<td>2</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td><a href="/feature/player/james_jones/index.html?locale=en_US">J.Jones</a></td>
<td>6</td>
<td>5</td>
<td>0</td>
<td>0</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<footer>
<nav>
<div class="footer-nav">
<div class="access-key-navigation">
<div>
<span>0.</span>
<a accesskey="0" href="/feature/index.html?locale=en_US">Home</a>
</div>
<div>
<span>1.</span>
<a accesskey="1" href="/feature/about/index.html?locale=en_US">About</a>
</div>
<div class="selected">
<span>2.</span>
<a accesskey="2" href="/feature/scores/index.html?locale=en_US">Scores</a>
</div>
<div>
<span>3.</span>
<a accesskey="3" href="/feature/news/index.html?locale=en_US">News</a>
</div>
<div>
<span>4.</span>
<a accesskey="4" href="/feature/players/index.html?locale=en_US">Players</a>
</div>
<div>
<span>5.</span>
<a accesskey="5" href="/feature/season/leaders.html?locale=en_US">Leaders</a>
</div>
<div>
<span>6.</span>
<a accesskey="6" href="/feature/standings/index.html?locale=en_US">Standings</a>
</div>
<div>
<span>7.</span>
<a accesskey="7" href="/feature/teams/index.html?locale=en_US">Teams</a>
</div>
</div>
<div class="copyright">
© 2016 NBA Media Ventures, LLC. All rights reserved
</div>
</div>
</nav>
</footer>
</div>
最初にコードを表示します。 BSを使用して 'tr'を取得し、その後BSを使用して' tr'で 'td'を取得し、後で索引' [n] 'を使用して結果のリストから値を取得できます。 – furas
あなたの現在の試みはどこですか? –
@PadraicCunninghamここに私の試みがあります:#insert BeautifulSoupコードここに素敵な人が基本的な実装を理解するのに役立ちます – kelemeno