diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2016-02-11 20:02:30 +0100 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2016-02-11 20:02:30 +0100 |
| commit | e43db7fd25798616ad38a959bd378bb765b9323c (patch) | |
| tree | 5d3db821ab5d4ffe124d755a125f4c5acfd724ff | |
| parent | d8c39f2b0571b9734259b2f9dc218eed24412332 (diff) | |
| download | phinde-e43db7fd25798616ad38a959bd378bb765b9323c.tar.gz phinde-e43db7fd25798616ad38a959bd378bb765b9323c.zip | |
support base href
| -rwxr-xr-x | bin/index.php | 8 | ||||
| -rw-r--r-- | src/phinde/LinkExtractor/Html.php | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/bin/index.php b/bin/index.php index 7550ad3..d110423 100755 --- a/bin/index.php +++ b/bin/index.php @@ -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'); diff --git a/src/phinde/LinkExtractor/Html.php b/src/phinde/LinkExtractor/Html.php index a6fa8ef..7b987e3 100644 --- a/src/phinde/LinkExtractor/Html.php +++ b/src/phinde/LinkExtractor/Html.php @@ -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) { |
