getContent() public method

Accessor for raw page information.
public getContent ( ) : string
return string Original text content of web page.
 function testUnifiedClickCanSubmit()
 {
     $browser = new SimpleBrowser();
     $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
     $browser->get('http://www.lastcraft.com/test/form.html');
     $this->assertTrue($browser->click('Go!'));
     $this->assertPattern('/go=\\[Go!\\]/', $browser->getContent());
 }
Exemplo n.º 2
0
<?php

error_reporting(E_ERROR);
require 'simpletest/browser.php';
$settingsJson = file_get_contents("credentials.json");
$settings = json_decode($settingsJson, true);
$browser = new SimpleBrowser();
$browser->get('https://apply.ukba.homeoffice.gov.uk/secure/protected/account');
$browser->setField('j_username', $settings['username']);
$browser->setField('j_password', $settings['password']);
$browser->click('Log in');
$pageText = $browser->getContent();
$numWords = array('first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth');
// Set the memorable word characters
foreach ($numWords as $index => $numWord) {
    $matches = array();
    if (preg_match('/The ' . $numWord . ' character.*<input[^>]+name[=]["]([^"]+)["]/msU', $pageText, $matches)) {
        $browser->setField($matches[1], substr($settings['memorable'], $index, 1));
    }
}
$browser->click('Confirm identity');
$browser->click('Book appointment');
$browser->setField('tabbedQuestions:screens:screen0:control0:j_id184:selectOneListBox', 'T2SPSKWORK');
$browser->click('Next');
$browser->setField('tabbedQuestions:screens:screen0:control1:j_id453:selectOneRadio', 'true');
$browser->click('Next');
//$browser->setField('tabbedQuestions:screens:screen0:control1:j_id490:dateInputControl:day', '31');
//$browser->setField('tabbedQuestions:screens:screen0:control1:j_id490:dateInputControl:month', '6');
//$browser->setField('tabbedQuestions:screens:screen0:control1:j_id490:dateInputControl:year', '2012');
//$browser->setField('tabbedQuestions:screens:screen0:control2:j_id555:dateInputControl:day', '31');
//$browser->setField('tabbedQuestions:screens:screen0:control2:j_id555:dateInputControl:month', '7');
Exemplo n.º 3
0
    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();
foreach ($dom->find('input') as $input) {
    array_push($arrValue, $input->value);
}
$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]);
print_r($arr);
scraperwiki::save(array('txtNumIPTU'), $arr);
//    $pageurl = "https://www3.prefeitura.sp.gov.br/sf8663/formsinternet/Principal.aspx";
//    $html = scraperWiki::scrape($pageurl);
Exemplo n.º 4
0
 function testDeleteRequest()
 {
     $browser = new SimpleBrowser();
     $browser->delete($this->samples() . 'request_methods.php');
     $this->assertEqual($browser->getResponseCode(), 202);
     $this->assertPattern('/Your delete request was accepted/', $browser->getContent());
 }
$evidence_sidebar = new DOMXPath($doc);
$xpath = "//div[@class='sidebar']/div/ul/li/a";
//arrived at via XPath Helper Chrome plugin. There may be a simpler query than this.
$hearings_links = $evidence_sidebar->query($xpath);
foreach ($hearings_links as $link) {
    //get URLs of each hearing date...
    $hearing_urls[] = 'http://www.levesoninquiry.org.uk' . $link->getAttribute('href');
}
//print_r($hearing_urls);
foreach ($hearing_urls as $url) {
    //scrape each hearing day result page for document links...
    $i = 0;
    $browser = new SimpleBrowser();
    $browser->useCookies();
    @$browser->get($url);
    $html_content = $browser->getContent();
    $hearing_page = new DOMDocument();
    $hearing_page->preserveWhiteSpace = false;
    $hearing_page->loadHTML($html_content);
    $transcript_links_list = new DOMXPath($hearing_page);
    $links_xpath = "//tr/td[2]/div/p/a";
    $evidence_links = $transcript_links_list->query($links_xpath);
    //echo $evidence_links->item(0)->nodeValue;
    $evidence_date_xpath = "/html/body[@class='page page-id-73 page-parent page-template page-template-template-evidence-php section-evidence']/div[@id='main']/div[@id='innermain evidence']/div[@id='content-box']/div[@id='primary']/table[@class='wide golden-one-two']/tr/td[1]/p";
    $evidence_date_results = $transcript_links_list->query($evidence_date_xpath);
    $evidence_date = date('Y-m-d', strtotime($evidence_date_results->item(0)->nodeValue));
    foreach ($evidence_links as $elink) {
        //scrape each document
        if (preg_match('#Transcript#i', $elink->nodeValue) && preg_match('#.txt#i', $elink->getAttribute('href'))) {
            //do only for transcripts
            //  echo $elink->nodeValue . "\n";
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);
            }
        }
    }
}
Exemplo n.º 7
0
 function testGet()
 {
     $browser = new SimpleBrowser();
     $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
     $this->assertTrue($browser->get($this->samples() . 'file.html'));
     $this->assertPattern('/Link to SimpleTest/', $browser->getContent());
     $this->assertEqual($browser->getTitle(), 'Link to SimpleTest');
     $this->assertFalse($browser->getResponseCode());
     $this->assertEqual($browser->getMimeType(), '');
 }