period = strtotime("1 week ago"); $this->output = ''; } /** * Should be load the page before the parsing or during * * @var boolean */ public $delayedLoad = false; public function loadStr($html) { $this->dom = new Crawler($html); } /** * Function to start the section. * @param whether to return or print the text * * @return string|void */ protected function startSection($return = false) { if (FORMAT === 'MARKDOWN') { $text = "\n#### ".$this->title."\n"; } if (FORMAT === 'HTML') { $text = "\n

".$this->title."

\n
\n"; } $this->output .= $text; } abstract protected function parse(); /** * System function to download page HTML. * * @return string */ public function get_text($url) { $client = new GuzzleClient([ 'timeout' => 30, ]); $response = $client->request('GET', $url, [ 'cookies' => $this->cookies, ]); return (string) $response->getBody(); } /** * Print the game line and catch all exceptions. * * @return void */ public function check() { try { $this->startSection(); try { $this->parse(); } catch (\Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; echo $e->getTraceAsString(); return; } $this->endSection(); if ($this->output === $this->startSection(true)) // nothing to print return; echo $this->output; } catch (Exception $e) { echo $e->getMessage(); echo $e->getTraceAsString(); } } /** * Check if URL corresponds to this source. * * @return boolean */ function checkPage($url) { return false; } }