我正在为我的学校评分系统处理数据,并试图弄清楚如何按类别提取数据。
这是原始 HTML:https ://pastebin.com/icbaemd7
现在,我编写了一个 Python 脚本:
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
chemData = ((soup.find_all('td')))
content = []
print chemData
print ""
for i in chemData:
content.append(i.getText().split('</td')[0])
for k in content:
print (k)
返回此结果:
Safety Contract Signed
1/1
8/13/2019
Student Profile Sheet Turned In
1/1
8/13/2019
Polyatomic Ion Quiz
10/10
8/19/2019
HW Quiz Ch. 3 Target 6
3/3
8/27/2019
HW Quiz (Ch. 3 Targets 1-6)
12/16
8/28/2019
Chapters 1 & 2 Formative Quiz
15/17
8/21/2019
Chapter 3 Formative Quiz
23.5/25
9/5/2019
Lab Report: Antifreeze Lab
10/10
8/21/2019
Types of Reactions Lab Report
11/12
8/23/2019
Hydrate Lab Report
10/10
8/29/2019
Lab Assessment - Types of Reactions Lab
10/15
8/26/2019
Lab Assessment: Hydrate Lab
10/10
9/3/2019
但是,我想将这些分类到 HTML 中存在的类别中。h3如果我使用而不是运行相同的脚本td,我会得到它们:
Homework
Formative Quizzes
Lab Reports
Lab Assessments
所以我的问题是:如何让它自动将实际作业分类到相应的类别中?
任何帮助将不胜感激。谢谢!
慕尼黑8549860
BIG阳
相关分类