https://www.basketball-reference.com/boxscores/201610250CLE.html
上記URLから上記画像の項目をスクレイピングするためにBeautifulSoupとrequestsを用いて、以下のようなコードを走らせたのですが情報を抜き出せませんでした。
python
1url2 = ('https://www.basketball-reference.com/boxscores/201610250CLE.html') 2res2 = requests.get(url2) 3stats = bs4.BeautifulSoup(res2.text, 'lxml') 4team1_q1 = stats.select('#line_score > tbody > tr:nth-of-type(2) > td:nth-of-type(2)') 5print(team1_q1) 6>> []
(上記画像の項目のselectorは#line_score > tbody > tr:nth-child(2) > td:nth-child(2)です。同ページの他の部分ではnth-childをnth-of-typeに変更して情報を抜き出していたので、ここでもその通りにしています。)
どのようにすれば該当項目の数字を抜き出すことができるでしょうか?
何卒よろしくお願いいたします。
あなたの回答
tips
プレビュー