+ /**
+ * Extract the title from a HTML URL
+ *
+ * @param string $url URL to a HTML page
+ *
+ * @return string|null NULL on error, title otherwise
+ */
+ public function getHtmlTitle($url)
+ {
+ libxml_use_internal_errors(true);
+ $doc = \DOMDocument::loadHTMLFile($url);
+ if ($doc === false) {
+ return null;
+ }
+ $sx = simplexml_import_dom($doc);
+ $title = (string) $sx->head->title;
+ if ($title == '') {
+ return null;
+ }
+ return $title;
+ }