猿问

如何使用 Python 和 BeautifulSoup 在此页面上选择 87%

我正在尝试从此页面中抓取一些数据。

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}} 而不是实际数字。


Cats萌萌
浏览 151回答 1
1回答

慕田峪7331174

它看起来确实是动态构造的。如果沿着硒路线走,您可以执行以下操作:from selenium import webdriverd = 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()
随时随地看视频慕课网APP

相关分类

Python
我要回答