public function Login() { $this->Revert(self::ROOT_URL . 'login'); $data = $this->Get(); $dom = new SimpleHTMLDom($data); $this->AuthToken($dom->find('[name=authenticity_token]', 0)->value); $dom->clear(); $this->Revert(self::ROOT_URL . 'session'); $this->AddVar('login', $this->username); $this->AddVar('password', $this->password); $this->SetMethod(POST); $this->AuthToken(); $data = $this->Get(); $dom = new SimpleHTMLDom($data); $error = $dom->find('[class=error-box]', 0); if ($error && !preg_match('~none~', $error)) return false; $houses = $dom->find('[class=house]'); foreach ($houses as $house) { $match = false; if (preg_match('~/houses/([0-9]+)/.+~', $house->href, $match)) { $house = new House($match[1], $house->text); array_push($this->houses, $house); if (!$this->house) $this->house = $house; } } $dom->clear(); return true; }
function str_get_dom($str, $lowercase = true) { $dom = new SimpleHTMLDom(); $dom->load($str, $lowercase); return $dom; }
/** * @param $value * * @return simple_html_dom_node|simple_html_dom */ public function createTextNode($value) { return @end(SimpleHTMLDom::str_get_html($value)->nodes); }