擅长:python、mysql、java
<p>您犯了两个小错误,但您的代码几乎是正确的:</p>
<ul>
<li>您需要删除<code>.find</code>之后的<code>BeautifulSoup</code>,因为这一行只用于创建汤,而不用于搜索任何内容</li>
<li>检索请求时需要使用<code>.text</code>而不是<code>.content</code>,因为BeautifulSoup使用的是字符串而不是字节。你知道吗</li>
</ul>
<p>以下是最终代码:</p>
<pre><code>import requests
from bs4 import BeautifulSoup
page = requests.get('https://www.espncricinfo.com/series/19430/scorecard/1187016/india-vs-bangladesh-1st-test-icc-world-test-championship-2019-2021')
soup = BeautifulSoup(page.text, 'html.parser')
scorecard = soup.find(id='gp-inning-01')
print(scorecard)
</code></pre>