$debug = true; // identify schools which already have at least one section spidered with a book with an isbn $schools = SchoolQuery::create()->orderBy('School.Slug', 'asc')->find(); list($goodSchools, $badSchools, $unsureSchools) = doMinimalTest($schools); // randomly spider bad schools until we've found a section with an isbn or are pretty sure that the school doesn't list isbns $newUnsureSchools = array(); foreach ($unsureSchools as $i => $school) { if (in_array($school->getSlug(), array('columbia'))) { $badSchools[] = $school; continue; } if (in_array($school->getSlug(), array('jwu', 'ohiostate', 'puc', 'spu'))) { $badSchools[] = $school; continue; } deleteCookieFile(); echo $school->getSlug(); $sectionClass = str_replace('School', 'Section', get_class($school)); $sectionSpiderer = new $sectionClass(); $goodCount = 0; $itemsCount = 0; while (!$goodCount && $itemsCount <= 10) { // we should already be spidered down to the department level for all schools $dept = DeptQuery::create()->filterBySchool($school)->where('Dept.SpideredAt < ?', time() - 60)->orWhere('Dept.SpideredAt IS NULL')->withColumn('RAND()', 'rand')->orderBy('rand')->findOne(); if (!$dept) { echo "WTF\n"; break; } echo $dept->getAbbr(); Spiderer::spider($dept, true, 0); $course = CourseQuery::create()->filterByDept($dept)->where('Course.SpideredAt < ?', time() - 60)->orWhere('Course.SpideredAt IS NULL')->withColumn('RAND()', 'rand')->orderBy('rand')->findOne();
<?php include 'global.php'; // LOGIN if (!isset($_GET['user']) or !$_GET['user'] or !isset($_GET['password']) or !$_GET['password']) { exit; } $user = $_GET['user']; $password = $_GET['password']; $error = 0; logAction('LOGIN: '******'POSTURL', 'http://www.csfd.cz/prihlaseni/prihlaseni/?do=form-submit'); define('POSTVARS', "username={$user}&password={$password}"); deleteCookieFile($user); $cookiename = getCookieFile($user); $ch = curl_init(POSTURL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, POSTVARS); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiename); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiename); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 1); // RETURN HTTP HEADERS curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // RETURN THE CONTENTS OF THE CALL $data = curl_exec($ch); if (curl_errno($ch)) { $error = curl_error($ch); } curl_close($ch); // CHECK ERROR CODE