我正在嘗試從此頁(yè)面中抓取一些數(shù)據(jù)。https://www.australiacouncil.gov.au/research/electorate-profiles/wright/#!Wright問(wèn)題是我無(wú)法使用 BeautifulSoup 和 Python 獲得 87%。當(dāng)我運(yùn)行時(shí):soup.find("div",{"class":"progress-bar-item progress-bar-item--text "})我得到 {{perc}} 而不是實(shí)際數(shù)字。
1 回答

慕田峪7331174
TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超13個(gè)贊
它看起來(lái)確實(shí)是動(dòng)態(tài)構(gòu)造的。如果沿著硒路線(xiàn)走,您可以執(zhí)行以下操作:
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()
添加回答
舉報(bào)
0/150
提交
取消