getField() public method

Finds the first match.
public getField ( string $label ) : string/boolean
$label string Field label.
return string/boolean
Exemplo n.º 1
0
    if (substr($strVerif, 10, 1) != $dac) {
    }
}
verificaDac();
require 'scraperwiki/simple_html_dom.php';
if (!file_exists('simpletest/browser.php')) {
    //first need to download SimpleTest
    $data = file_get_contents("http://aendrew.com/sites/all/libraries/simpletest_1.1alpha3.tar.gz");
    file_put_contents("simpletest.tar.gz", $data);
    exec('tar -xzvf simpletest.tar.gz');
}
require_once 'simpletest/browser.php';
$browser = new SimpleBrowser();
$browser->useCookies();
$browser->get('https://www3.prefeitura.sp.gov.br/sf8663/formsinternet/Principal.aspx');
$viewstate = $browser->getField('__VIEWSTATE');
// $browser->setField('__VIEWSTATE', $viewstate);
$browser->setField('txtSetor', '003');
$browser->setField('txtQuadra', '006');
$browser->setField('txtLote', '0001');
$browser->setField('txtDigito', '1');
$browser->clickSubmitByName('_BtnAvancarDasii');
//$results = $browser->getField("txtNome");
$results = $browser->getContent();
$dom = new simple_html_dom();
$dom->load($results);
$arrName = array();
foreach ($dom->find('input') as $input) {
    array_push($arrName, $input->name);
}
$arrValue = array();
function getPage($s, $q, $lmin, $lmax)
{
    require_once 'simpletest/browser.php';
    $browser = new SimpleBrowser();
    $browser->useCookies();
    for ($r = $lmin; $r <= $lmax; $r++) {
        $browser->get('https://www3.prefeitura.sp.gov.br/sf8663/formsinternet/Principal.aspx');
        $viewstate = $browser->getField('__VIEWSTATE');
        $setor = $s;
        $quadra = $q;
        $lote = leading_zeros(number_format($r, 0, '', ''), 4);
        //$lote = number_format($r);
        $browser->setField('txtSetor', $setor);
        $browser->setField('txtQuadra', $quadra);
        $browser->setField('txtLote', $lote);
        $browser->setField('txtDigito', verificaDac($setor, $quadra, $lote));
        $browser->clickSubmitByName('_BtnAvancarDasii');
        $results = $browser->getContent();
        $dom = new simple_html_dom();
        $dom->load($results);
        $arrName = array();
        foreach ($dom->find('input') as $input) {
            array_push($arrName, $input->name);
        }
        $arrValue = array();
        foreach ($dom->find('input') as $input) {
            array_push($arrValue, $input->value);
        }
        if (empty($arrValue)) {
        } else {
            if ($arrValue[6] == "") {
                var_dump($lote);
            } else {
                $arr = array($arrName[5] => $arrValue[5], $arrName[6] => $arrValue[6], $arrName[7] => $arrValue[7], $arrName[8] => $arrValue[8], $arrName[9] => $arrValue[9], $arrName[11] => $arrValue[11]);
                scraperwiki::save(array('txtNumIPTU'), $arr);
            }
        }
    }
}