0

Im writing a program that goes to my school grades site and takes my grades and makes them my desktop background but once i get to my grades i cant get how to parse them out of the large table

Here is my code:

from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome()
driver.get("https://ps.rsd.edu/public/")

elem = driver.find_element_by_name("account")
elem.send_keys("Username")
elem2 = driver.find_element_by_name("pw")
elem2.send_keys("Password")
elem.send_keys(Keys.RETURN)
html = driver.page_source
soup = BeautifulSoup(html)
print soup
driver.quit()

print "done"

this prints the source for the page but i want to get the grades out of a row called S2 sorry its kinda hard because i cant show you the actual site

here are all the names of the rows in the table:

<table class="grid">
<tr><th class="center" colspan="25">Attendance By Class</th></tr>
<tr class="center th2">
<th rowspan="2">Exp</th>
<th colspan="5">Last Week</th><th colspan="5">This Week</th><th rowspan="2">Course</th>
<th rowspan="2">Q1</th>
<th rowspan="2">Q2</th>
<th rowspan="2">S1</th>
<th rowspan="2">Q3</th>
<th rowspan="2">Q4</th>
<th rowspan="2">S2</th>
<th rowspan="2">Absences</th>
<th rowspan="2">Tardies</th>
</tr>

and this is an example row:

<a href="scores.html?  frn=004711281&begdate=01/23/2013&enddate=06/07/2013&fg=S2">B<br>84</a></td>
<td><a
4

1 回答 1

1

此资源可能对您有所帮助:在 selenium 中定位元素

你可以尝试使用

find_element_by_link_text

以及您的一门课程的名称,以获得包含该课程成绩的元素

于 2013-05-07T01:11:49.577 回答