前提・実現したいこと
PythonでスクレイピングをNBAの試合情報を自動で取得する
発生している問題・エラーメッセージ
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?
と表示され、ネットでエラーの内容を検索してもうまく実行されませんでした。ご指導していただきたいです。
該当のソースコード
#今日の試合結果を取得する
import requests
from bs4 import BeautifulSoup
import datetime
#日付の設定
get_data_date = datetime.date.today().strftime("%Y%M%D")
#URLの指定
url = "https://sports.yahoo.co.jp/basket/nba/schedule/?type=reg&date="+str(get_data_date)
#URLへアクセス
res = requests.get(url)
soup = BeautifulSoup(res.text,"html5lib")
#試合日程を取得
game_date = soup.find_all("td",class_='date')
game_team = soup.find_all("td",class_='team')
game_score = soup.find_all("td",class_='score')
#試合情報取得
a = 0
b = 0
for text in game_date[0:100]:
print(text.text) for team_name in game_team[int(a):int(a+2)]:
print(team_name.text.strip())
a += 1
try:
print(game_score[int(b)].find("span").text)
b += 1
except:
break
print("---------------")
自分で調べたことや試したこと
①pip install html5lib⇨Requirement already satisfied
あなたの回答
tips
プレビュー