我正试图通过网络刮蟋蟀得分webiste得到一个记分卡。 但是我得到了这个属性错误:
回溯(最近一次呼叫最后一次):
**文件“J:/Python Programs/Web Scraper/ESPN Cric信息.py“,第6行,在”
soup = BeautifulSoup.find(page.content, 'html.parser')
文件“J:\Python Programs\Web Scraper\venv\lib\site packages\bs4\元素.py,第1282行,查找 l=自我发现(名称,属性,递归,文本,1,****kwargs**) ** AttributeError:'bytes'对象没有属性'find\u all'***
我的代码是:
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.find(page.content, 'html.parser')
scorecard = soup.find(id='gp-inning-01')
print(scorecard)
如果你能解决这个问题,那将是一个很大的帮助。你知道吗
您犯了两个小错误,但您的代码几乎是正确的:
.find
之后的BeautifulSoup
,因为这一行只用于创建汤,而不用于搜索任何内容.text
而不是.content
,因为BeautifulSoup使用的是字符串而不是字节。你知道吗以下是最终代码:
试试这个
相关问题 更多 >
编程相关推荐