Changeset - e31a9001e849
[Not reviewed]
default
0 1 0
Ethan Zonca - 15 years ago 2010-10-16 01:12:57
ez@ethanzonca.com
Get the correct table. Test to see if this works with the nested table setup
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
school.d/umich.inc
Show inline comments
 
@@ -29,7 +29,7 @@ EOF;
 
}
 

	
 
/** Parse html at URL into array, first row is row headers */
 
function table_parse($url) {
 
function umich_table_parse($url) {
 
  $arr = array();
 
  $dom = new DOMDocument;
 
  $html = file_get_contents($url);
 
@@ -39,7 +39,7 @@ function table_parse($url) {
 
  $dom->loadHTML($html);
 
  $dom->preserveWhiteSpace = false;
 
  $tables = $dom->getElementsByTagName('table');
 
  $rows = $tables->item(0)->getElementsByTagName('tr'); // Get first table on page 
 
  $rows = $tables->item(2)->getElementsByTagName('tr'); // Get first table on page 
 
  foreach ($rows as $rownum => $row) {
 
    $cols = $row->getElementsByTagName('td');
 
    foreach($cols as $colnum => $col){
 
@@ -59,7 +59,7 @@ function umich_crawl($season, $year) {
 
  $season = strtolower($season);
 
  $tables = array();
 
  foreach($departments as $department) {
 
    $tables[$department] = table_parse($basepath . '&department=' . $department . '&allsections=true&show=1000');
 
    $tables[$department] = umich_table_parse($basepath . '&department=' . $department . '&allsections=true&show=1000');
 
  }
 
  return $tables;
 
}
0 comments (0 inline, 0 general)