【发布时间】:2021-05-27 11:39:15
【问题描述】:
对于上下文,我对 Python 还是很陌生。我正在尝试使用 bs4 从https://bigfuture.collegeboard.org/college-university-search/university-of-california-los-angeles 中解析一些数据
确切地说,我想在网页的“支付”部分获取 57% 的数字。 我的问题是bs4只会返回HTML的第一层,而我想要的数据是深深嵌套在代码中的。我认为它低于 17 个 div。
这是我的python代码:
import requests
import bs4
url = 'https://bigfuture.collegeboard.org/college-university-search/university-of-california-los-angeles'
res = requests.get(url)
soup = bs4.BeautifulSoup(res.text, "html.parser")
print(soup.find_all("div", {"id": "gwtDiv"}))
(这会返回[<div class="clearfix margin60 marginBottomOnly" id="gwtDiv" style="min-height: 300px;height: 300px;height: auto;"></div>] 里面的元素都不显示。)
【问题讨论】:
标签: python html web-scraping beautifulsoup