Python 为html返回空的findAll

Python 为html返回空的findAll,python,html,parsing,beautifulsoup,findall,Python,Html,Parsing,Beautifulsoup,Findall,我正在使用BeautifulSoup模块解析一个html文件,我想从中提取某些信息。特别是比赛分数和球队名称 但是,当我使用findAll函数时,它会不断地为肯定在html中的字符串返回空值。如果有人能解释我做错了什么,我将不胜感激。请参阅下面的代码 import urllib import bs4 import re from urllib.request import urlopen as uReq from bs4 import BeautifulSoup as soup my_url

我正在使用
BeautifulSoup
模块解析一个html文件,我想从中提取某些信息。特别是比赛分数和球队名称

但是,当我使用
findAll
函数时,它会不断地为肯定在html中的字符串返回空值。如果有人能解释我做错了什么,我将不胜感激。请参阅下面的代码

import urllib
import bs4
import re
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup

my_url = 'http://www.foxsports.com/mlb/scores?season=2017&date=2017-05-09'
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
# html parser
page_soup = soup(page_html, "html.parser")
container = page_soup.findAll("div",{"class":"wisbb_teams"})
print(len(container))

我认为您使用的语法是旧版本的
beautifulsou
,请尝试类似于
查找所有的
snake\u案例(请参阅)

旧的API使用CamelCase,但bs4使用snake_case

另外,请注意
find\u all
takes可以使用
class
参数通过class查找

有关更多信息,请参阅此答案

另外,确保您正在寻找正确的类名!我看不到你要找的课程,而是这些:


这个文字,
wisbb\u teams
,似乎根本没有出现在
my\u url
的HTML中。抓取成功了吗?嘿,谢谢!我可以问一下你是如何找到包含wisbb的潜在类的吗?而且,至少当我检查页面上的元素时,这样的类是存在的。你知道为什么会这样吗?我想要的信息嵌套在html中的许多类中,这就是我找不到它的潜在原因吗?我只是通过使用firefox检查控制台,搜索字符串wisbb:)得到了该图像。我没有看到任何wisb_团队
from bs4 import BeautifulSoup
# ...
page_html = uClient.read()
page_soup = BeautifulSoup(page_html, "html.parser")
list_of_divs = page_soup.find_all("div", class_="wisbb_name")
print(len(list_of_divs))