sanitize title better
[phinde.git] / src / phinde / LinkExtractor / Html.php
index 0d6f3d8aa1159bd9053801464033abf063fad09b..a6fa8efef8fe9725722bf94bbd137671b73e3afe 100644 (file)
@@ -2,6 +2,7 @@
 namespace phinde\LinkExtractor;
 
 use phinde\LinkInfo;
+use phinde\Helper;
 
 class Html
 {
@@ -21,10 +22,10 @@ class Html
 
         $dx = new \DOMXPath($doc);
 
-        $meta = $dx->evaluate('/html/head/meta[@name="robots" and @value]')
+        $meta = $dx->evaluate('/html/head/meta[@name="robots" and @content]')
             ->item(0);
         if ($meta) {
-            $robots = $meta->attributes->getNamedItem('value')->textContent;
+            $robots = $meta->attributes->getNamedItem('content')->textContent;
             foreach (explode(',', $robots) as $value) {
                 if (trim($value) == 'nofollow') {
                     //we shall not follow the links
@@ -36,10 +37,10 @@ class Html
         $links = $dx->evaluate('//a');
         //FIXME: link rel, img, video
 
-        $alreadySeen = array();
+        $alreadySeen = array($url => true);
 
         foreach ($links as $link) {
-            $linkTitle = $link->textContent;
+            $linkTitle = Helper::sanitizeTitle($link->textContent);
             $href = '';
             foreach ($link->attributes as $attribute) {
                 if ($attribute->name == 'href') {