// Perform Query $result = $db->query("SELECT * from Bill"); if (!$result) { $message = 'Invalid query: ' . $db->error . "\n"; die($message); } if ($result->num_rows <= 0) { die($message = 'no result query: ' . $db->error . "\n"); } // output data of each row while ($row = $result->fetch_assoc()) { $sumHTML = $row['sumHTML']; $coActorHTML = $row['coActorHTML']; $id = $row['id']; echo "Working on {$id}\n"; $bill = getBill($id, $sumHTML); $actors = getActors($coActorHTML); if ($dryrun) { print $bill->toSummaryString(); if ($bill->summary === "") { echo "\nNo summary! check http://likms.assembly.go.kr/bill/jsp/SummaryPopup.jsp?bill_id={$bill->id}\n"; } $line = readline("\n\nOK?[y]/n: "); if ($line === 'n') { exit(-1); } continue; // DO not put something to DB } // insert bill and actors to DB $bill->update($db);
<?php include_once 'Bill.php'; // Test mode if ($argv[0] == 'getBill.php') { $b = getBill("PRC_A1J5J1E1N1K0Q1O4A4V8L1H4C2Q4C9"); echo $b->toString(); } function getBill($id, $content) { $txt = strip_tags($content); $tokens = preg_split('/\\n+/', $txt); $idx = 0; $title = ""; $summary = ""; $start = false; foreach ($tokens as $line) { $line = trim($line); // let's trim if (strpos($line, "제안이유") !== false) { $start = true; } if (!$start) { continue; } if ($line === "" || strpos($line, "제안이유") !== false || strpos($line, "http://") !== false) { continue; } // assume the first text is the title if ($idx++ == 0) { $title = $line;