support base href
authorChristian Weiske <cweiske@cweiske.de>
Thu, 11 Feb 2016 19:02:30 +0000 (20:02 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Thu, 11 Feb 2016 19:02:30 +0000 (20:02 +0100)
bin/index.php
src/phinde/LinkExtractor/Html.php

index 7550ad3..d110423 100755 (executable)
@@ -72,6 +72,14 @@ $doc = new \DOMDocument();
 @$doc->loadHTML($res->getBody());
 $dx = new \DOMXPath($doc);
 
+$xbase = $dx->evaluate('/html/head/base[@href]')->item(0);
+if ($xbase) {
+    $base = $base->resolve(
+        $xbase->attributes->getNamedItem('href')->textContent
+    );
+}
+
+
 //remove script tags
 removeTags($doc, 'script');
 removeTags($doc, 'style');
index a6fa8ef..7b987e3 100644 (file)
@@ -22,6 +22,13 @@ class Html
 
         $dx = new \DOMXPath($doc);
 
+        $xbase = $dx->evaluate('/html/head/base[@href]')->item(0);
+        if ($xbase) {
+            $base = $base->resolve(
+                $xbase->attributes->getNamedItem('href')->textContent
+            );
+        }
+
         $meta = $dx->evaluate('/html/head/meta[@name="robots" and @content]')
             ->item(0);
         if ($meta) {