} else {
$topCandidate->innerHTML = $page->documentElement->innerHTML;
$page->documentElement->innerHTML = '';
+ $this->reinitBody();
$page->documentElement->appendChild($topCandidate);
}
} else {
{
// TODO: find out why element disappears sometimes, e.g. for this URL http://www.businessinsider.com/6-hedge-fund-etfs-for-average-investors-2011-7
// in the meantime, we check and create an empty element if it's not there.
- if (!isset($this->body->childNodes)) $this->body = $this->dom->createElement('body');
- $this->body->innerHTML = $this->bodyCache;
+ $this->reinitBody();
if ($this->flagIsActive(self::FLAG_STRIP_UNLIKELYS)) {
$this->removeFlag(self::FLAG_STRIP_UNLIKELYS);
public function removeFlag($flag) {
$this->flags = $this->flags & ~$flag;
}
+
+ /**\r
+ * Will recreate previously deleted body property\r
+ *\r
+ * @return void\r
+ */\r
+ protected function reinitBody() {\r
+ if (!isset($this->body->childNodes)) {\r
+ $this->body = $this->dom->createElement('body');\r
+ }\r
+ $this->body->innerHTML = $this->bodyCache;\r
+ }
+
}
?>
\ No newline at end of file