You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Selenium Python无法提取含动态span的p标签文本数据

提取捐赠者名单文本失败,求解决方法

我尝试从指定页面提取捐赠者文本数据,页面截图如下:
捐赠荣誉榜页面截图

怀疑无法获取文本是因为目标p标签内存在数量不固定的span标签,以下是我使用的Selenium Python代码:

driver = webdriver.Chrome("chromedriver.exe")
driver.maximize_window()
driver.get("https://www.lemoyne.edu/Give/Information-for-Donors/Honor-Roll/1954")
time.sleep(10)

donors= driver.find_elements("xpath",'//div[@class = "container"]/div[@class="donorcolumn"]/p')
donors

##Result:- Empty List []

for donor in donors:
   print(donor.get_attribute("innerHTML"))

##Result:- Empty List []

for donor in donors:
   print(donor.text)

## Result:- Empty List []

预期输出为:

The Hon. Salvatore J. Arrigo Jr. '54 and Mrs. Elizabeth J. Arrigo (35) President's Club Annual Fund Previous President's Club Member
Margaret A. Dwyer '54, L.C.H.D. '94 (35) President's Club Previous President's Club Member
Frances Morrison Scott Estate (1) Previous President's Club Member
Rosemary T. Fatcheric '54 (12)
Jo-An Feyerabend '54 (35)
James H. Greiner '54 (11) Annual Fund
Charles R. Nojaim '54 and Patricia Nojaim (22)
Marie Dinehart Rathbun '54 (22)
Audrey Zillioux Rich '54 (30) Annual Fund
David G. Schoeneck '54 and Therese Sharpe Schoeneck '54 (25) Annual Fund
John H. Senecal '54 (14)
John B. Vita '54 and Mary M. Vita (1)
Eugene P. Vukelic '54 (8) President's Club Annual Fund Previous President's Club Member

恳请各位提供建议或帮助,谢谢!

内容的提问来源于stack exchange,提问作者Umesh Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 17:18:14