我正在尝试从此页面中抓取一些数据。https://www.australiacouncil.gov.au/research/electorate-profiles/wright/#!Wright问题是我无法使用 BeautifulSoup 和 Python 获得 87%。当我运行时:soup.find("div",{"class":"progress-bar-item progress-bar-item--text "})我得到 {{perc}} 而不是实际数字。
1 回答

慕田峪7331174
TA贡献1828条经验 获得超13个赞
它看起来确实是动态构造的。如果沿着硒路线走,您可以执行以下操作:
from selenium import webdriver
d = webdriver.Chrome(r'path\chromedriver.exe')
d.get('https://www.australiacouncil.gov.au/research/electorate-profiles/wright/#!Wright')
print(d.find_element_by_css_selector('.dzs-progress-bar strong').text)
d.quit()
添加回答
举报
0/150
提交
取消