使用Beautifulsoup进行网页爬取:找不到课程

时间:2020-03-27 19:30:34

标签: python web-scraping beautifulsoup

我是python的新手,正在尝试使用beautifulsoup进行网络抓取。在观看了一些youtube视频并不断地寻找关于stackflow的答案之后,我决定要发布帮助。

使用以下代码,我希望从网站中提取数据。我注意到当我打印(len(div))时列出了一个3 div,但是网页上有几个div。其他帖子指向汤.findAll('div',{'class':'response-text-label'})作为解决方案,但是,当我打印()该代码(和其他类似代码)时,得到[]为pyCharm的结果。

enter code here 从bs4进口BeautifulSoup作为汤 从urllib.request中导入urlopen作为uReq

my_url = 'https://coronavirus.jhu.edu/map.html'
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()

page_soup = soup(page_html, 'html.parser')
total_cases = page_soup.findAll('div', {'class': 'responsive-text-label'})

print(total_cases)

RESULTS FROM PYCHARM
[]

在此先感谢您抽出宝贵的时间来帮助我。

0 个答案:

没有答案