aatest

[insert_php]

function get_string_between($string, $start, $end, $after){
$string = ” “.$string;
$ini = strpos($string,$start, $after);
if ($ini == 0) return “”;
$ini += strlen($start);
$len = strpos($string,$end,$ini) – $ini;
return substr($string,$ini,$len);
}

$fname = WP_PLUGIN_DIR.”/mgaleg/hearings.txt”;
$myfile = fopen($fname, “w”) or die(“Unable to open file!”);

$bills = array(“HB0388″,”SB0602″,”HB0791″,”SB0388″,”HB0659″,”HB1059″,”SB0686″,”HB0244″,”SB0526″,”HB0303″,”SB0111″,”HB0622″,”SB0603″,”HB0301″,”SB0414″,”HB0304″,”SB0652″,”HB0980″,”SB0340″,”HB0698″,”SB0566″,”HB0337″,”SB0366”);
$arrlength=count($bills);
for($x=0;$x<$arrlength;$x++) { //Specify your URL $URL = "http://mgaleg.maryland.gov/webmga/frmMain.aspx?pid=billpage&stab=03&id=".$bills[$x]."&tab=subject3&ys=2015RS"; $page = file_get_contents($URL); if ($bills[$x][0] == 'S') { $endstring = " House

“;
} else {
$endstring = “

Senate

“;
}
$before = strpos($page, $endstring, 0);
if ($before != FALSE) {
$page = substr($page, 0, $before); // truncate the page
}

$after = strpos($page, “>Entitled:

“, 0);
$title = get_string_between($page, “–>”, “

“, $after);
$committee = get_string_between($page, “>First Reading “, “

“, $after);

// get the last hearing date
$pos = $after;
while ($pos>5) {
$temp = get_string_between($page, “>Hearing “, “

“, $pos);
if (strlen($temp)>0) $hearing = $temp;
$pos = strpos($page, “>Hearing “, $pos) + 4;
}

// also get the last action
$lastaction = “no action”;
$pos = $after;
while ($pos>5) {
$temp = get_string_between($page, ‘billleftcells”>’, “

“, $pos);
if (strlen($temp)>0) $lastaction=$temp;
$pos = strpos($page, ‘billleftcells”>’, $pos) + 4;
}

$txt = “$bills[$x]; $title; $committee; $hearing; $lastaction \n”;
echo $txt;
fwrite($myfile, $txt);

} // end of for loop

fclose($myfile);

[/insert_php]