【发布时间】:2017-05-12 14:59:12
【问题描述】:
我正在使用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))
【问题讨论】:
-
wisbb_teams的文字似乎根本没有出现在my_url的 HTML 中。 -
抓取成功了吗?
标签: python html parsing beautifulsoup findall