function do_bill_insert($bill_key) { include_once 'scrape_and_insert.inc.php'; $mvScrape = new MV_BaseScraper(); $myBillScraper = new MV_BillScraper(); $congressNum = 111; print "do_bill_insert:: {$bill_key} downloading fresh bills.index.xml....\n "; //grab bill list with categories from govtrack $raw_govtrack_bill_data = $mvScrape->doRequest('http://www.govtrack.us/data/us/' . $congressNum . '/bills.index.xml', array(), true); //turn bill data into an array: preg_match_all("/<bill\\s([^>]*)\\>/U", $raw_govtrack_bill_data, $nodes); print "found " . count($nodes[1]) . " bills \n"; $types = array('type', 'number', 'title', 'official-title', 'status', 'last-action'); $billAry = array(); foreach ($nodes[1] as $bill_str) { $bObj = array(); preg_match_all('/([^=]*)="([^"]*)"/', $bill_str, $matches); foreach ($matches[1] as $inx => $tkey) { if (in_array(trim($tkey), $types)) { $bObj[trim($tkey)] = $matches[2][$inx]; } } //setup some keys: $bObj['GovTrackID'] = $bObj['type'] . $congressNum . '-' . $bObj['number']; $bObj['ThomasID'] = 'd' . $congressNum . ':' . $bObj['type'] . $bObj['number'] . ':'; $bObj['OpenCongressBillID'] = $congressNum . '-' . $bObj['type'] . $bObj['number']; $bObj['CongressSession'] = $congressNum; $tp = explode(':', $bObj['title']); $bObj['Bill Key'] = $tp[0]; $maplightBillId = get_map_light_bill_id($bObj); if ($maplightBillId === false) { print "Could not find maplight id for bill: " . $bObj['type'] . '+' . $bObj['number'] . "\n"; $bObj['MapLightBillID'] = false; } else { $bObj['MapLightBillID'] = $maplightBillId; //now that we do have a maplight key get the interest info: $bObj['interests'] = $myBillScraper->proccMapLightBillIntrests($maplightBillId); } $billAry[] = $bObj; //do proccess the bill (insert into the wiki) print "ProccessBill::"; $myBillScraper->processBill($bObj['GovTrackID'], $bObj['Bill Key'], $bObj['OpenCongressBillID'], $bObj['MapLightBillID'], false, false); } }